SQL Interview Questions
SQL Interview Questions
A primary key is a combination of fields which uniquely specify a row. This is a special kind of
unique key, and it has implicit NOT NULL constraint. It means, Primary key values cannot be
NULL.
7. What is a constraint?
Constraint can be used to specify the limit on the data type of table. Constraint can be
specified while creating or altering the table statement.
• Sample of constraint are. NOT NULL - Restricts NULL value from being inserted into a column.
• CHECK - Verifies that all values in a field satisfy a condition.
• DEFAULT - Automatically assigns a default value if no value has been specified for the field.
• UNIQUE - Ensures unique values to be inserted into the field.
• INDEX - Indexes a field providing faster retrieval of records.
• PRIMARY KEY - Uniquely identifies each record in a table.
• FOREIGN KEY - Ensures referential integrity for a record in another table.
8. How Do you find all Employees with its managers? (Consider there is manager id also in
Employee table)
Select e.employee_name,m.employee name from Employee e,Employee m where
e.Employee_id=m.Manager_id;