Skip to main content

Posts

Showing posts with the label Database

Varchar(-1)

Today we are going to discuss about the varchar(-1). why we are using varchar(-1) and what is the purpose of it. Varchar(-1) In case if we user doesnt know the column length. how many character will user enter: so it is better to go with vachar(-1) Consider the column address is of varchar(-1), now in case 1 when user enter a data of size varchar(10) the size of the column dynamically accepts the user data of size varchar 10. later in case 2 user tries to insert data of size varchar 100. now the column address can accept user data of size 100.  NOTE: The size of the column will change automatically when user tries to insert a data of size greater than previous inserted data.

Difference between Lock and Nolock

Lock Lock in  MSSQL is used to prevent concurrent access of tables. It is widely used to application that have large number of users who access database. In case if a user tries to alter a table the table will be in lock state so that no other user can try to alter the table until the lock release.  In this case User 1 is trying to alter the table in database. User 2 has to wait until the lock is released by user 1. After that User 2 will put lock and execute the query. In case if user fails to use lock it will results in error Note: Lock is used in DML statement. Nolock  Nolock is used so that two or more user can access the table simultaneously.It widely used in DDL statement.    This is many number of user can select (View) data from table. select statement is similar to read. Where as DML is similar to write. By using nolock the data retrieval speed is increased for the user. There is no need wait until other user data selection ends.