Sql Interview Question and Answers
6. |
Define Primary Key? |
|
- The primary key is the columns used to uniquely identify each row of a table.
- A table can have only one primary key.
- No primary key value can appear in more than one row in the table.
|
|
Baburao Adkane, said |
Mar 16, 2014 |
A primary key is a key uniquely identifies a field/row of the table. A primary key does not contain a NULL value. A table can have only one primary key. A primary key is applicable to one or more fields of the table. A primary key is applied to more than one field then it is called the Candidate Key.
|
|
7. |
Define Unique Key? |
|
Unique key is a one or more column that must be unique for each row of the table. It is similar to primary key. Primary key column will not accept a null. Whereas the unique key column will accept a null values. |
|
|
8. |
Compare and contrast TRUNCATE and DELETE for a table? |
|
Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete. |
|
|
9. |
What is cursors? |
|
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time. |
|
|
10. |
Define Foreign Key? |
|
A foreign Key is a combination of columns with value is based on the primary key values from another table. A foreign key constraint also known as Referential Integrity Constraint. |
|
|