SQL Server Interview Tips
SQL Server Interview Tips
Database/SQL Questions
1. What’s the difference between a primary key and a unique key?
Both primary key and unique enforce uniqueness of the column on which they are
defined. But by default primary key creates a clustered index on the column, where are
unique creates a nonclustered index by default. Another major difference is that, primary
key doesn’t allow NULLs, but unique key allows one NULL only.
Joins are used in queries to explain how different tables are related. Joins also let you
select data from a table depending upon data from another table. Types of joins: INNER
JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER
JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.
You can use index hint (index=index_name) after the table name. SELECT au_lname
FROM authors (index=aunmind)
6. What is sorting and what is the difference between sorting and clustered
indexes?
The ORDER BY clause sorts query results by one or more columns up to 8,060 bytes.
This will happen by the time when we retrieve data from database. Clustered indexes
physically sorting data, while inserting/updating the table.
Referential integrity refers to the consistency that must be maintained between primary
and foreign keys, i.e. every foreign key value must have a corresponding primary key
value
© Copyright 2004-06 Trivandrum Microsoft Usergroup