CLUSTERED INDEX VS NON CLUSTERED INDEX Clustered Index Only one clustered index can be there in a table because of the sorted order Sort the records and store them physically according to the order Data retrieval is faster than non-clustered indexes Do not need extra space to store logical structure A primary key by default creates a clustered index on it. Non Clustered Index There can be any number of non-clustered indexes in a table because of the number of unique keys we can create. Do not affect the physical order. Create a logical order for data rows and use pointers to physical data files Data insertion/update is faster than clustered index Use extra space to store logical structure A unique key/keys by dafault created an unclustered index on it. In Depth Explanation: Clustered Technically speaking, a clustered index is a B-Tree data structure where all the rows in a table are stored at the leaf level of the index. In other words, a clustered ind...
Popular posts from this blog
SQL JOINS Tutorial: INNER, OUTER, LEFT, RIGHT, CROSS What are JOINS? Joins help retrieving data from two or more database tables. The tables are mutually related using primary and foreign keys. id first_name last_name movie_id 1 Adam Smith 1 2 Ravi Kumar 2 3 Susan Davidson 5 4 Jenny Adrianna 8 6 Lee Pong 10 id title category 1 ASSASSIN'S CREED: EMBERS Animations 2 Real Steel(2012) Animations 3 Alvin and the Chipmunks Animations 4 The Adventures of Tin Tin Animations 5 Safe (2012) Action 6 Safe House(2012) Action 7 GIA 18+ 8 Deadline 2009 18+ 9 The Dirty Picture 18+ 10 Marley and me Romance Types of joins Cross JOIN Cross JOIN is a simplest form of JOINs which matches each row from one database table to all rows of another. In other words it gives us combinations of each row of first table with all records in second table. Suppose we want to get all member records against all the movie records, we can use the script shown below to ge...
ANSI_NULL and QUOTED_IDENTIFIER: ANSI_NULL: When ever we are creat ing or altering th e SQL objects like the Stored Procedure s and the User Defined Functions at t h at time most of us use this. Let us understand this better with an example let us create a table and insert some records, CREATE TABLE #Demo ( FName VARCHAR ( 200 ), LName Varchar ( 200 ) ) Insert #Demo values ( 'Ravi' , 'Shekhar' ) Insert #Demo values ( 'Isha' ,NULL ) Insert #Demo values ( 'Santosh' , 'Thakur' ) SQL Server tend s to behave differently when ever we use either the SET ANSI_NULL ON or the OFF . SET ANSI_NULL ON; If the ANSI_NULL is on then the comparison with NULL value with = or <> returns false. SET ANSI_NULLS ON SELECT * FROM #Demo WHERE LName = NULL SELECT * FROM #De...
Comments
Post a Comment