Monday, March 16, 2009
What is the difference between Primary key and foreign key?
Primary key is used to identify a row in a table and it does not allow null values. It avoids duplication of rows. Whereas foreign key refers to a column or combination of columns included in the definition of referential integrity. Foreign key will allow "Null values" and "Duplicate values" and it refers to a primary key in another table.
What is the difference between primary key and unique key?
Primary key are entity integrity constraints Primary key allows each row in a table to be uniquely identified and ensures that no duplicate rows exist and no null values are entered. Unique key constraint is used to prevent the duplication of key values within the rows of a table and allow null values.
What is the difference between candidate key and composite key?
CANDIDATE KEY:-A nominee's for primary key field are know as candidate key.
COMPOSITE KEY:- Creating more than one primary key are jointly known as composite key.
COMPOSITE KEY:- Creating more than one primary key are jointly known as composite key.
What is the difference between delete and truncate command?
Delete command remove the rows from table based on the condition provided in where clause. Truncate will remove all the data from table. After deleting we can rollback but after truncate we can’t rollback.
The other main difference are below:-
a) Truncate is DDL command while DELETE is DML command.
b) TRUNCATE resets the identity of the tables while DELETE doesn’t reset the identity of the table.
c) TRUNCATE can not be rolled back while delete can be rolled back.
The other main difference are below:-
a) Truncate is DDL command while DELETE is DML command.
b) TRUNCATE resets the identity of the tables while DELETE doesn’t reset the identity of the table.
c) TRUNCATE can not be rolled back while delete can be rolled back.
What is the difference between HAVING clause and WHERE clause?
HAVING can be used only with select statement. Generally, HAVING is used with GROUP BY clause. When GROUP BY is not used, HAVING behaves like WHERE clause.
What is CHECK constraint?
A CHECK constraint is used to limit the values that can be placed in a column. It can be used to enforce domain integrity.
What is not null constraint?
A NOT NULL constraint enforces that column will not accept NULL values.
What is the difference between functions and stored procedures?
Functions can be used in the SQL statement anywhere in the where/having/select statement whereas stored procedure cannot. Functions that return tables can be treated as another rowset.
What is inner join?
A join that displays only the rows that have a match in both joined tables is known as inner join.
Subscribe to:
Posts (Atom)