SQL Query Interview Questions and Answers
Ques 11. Explain the difference between DELETE and TRUNCATE commands.
DELETE is used to remove rows from a table based on a condition. TRUNCATE removes all rows from a table without logging individual row deletions.
Example:
DELETE FROM table WHERE condition;
Is it helpful?
Add Comment
View Comments
Ques 12. What is a foreign key?
A foreign key is a column or a set of columns in a table that refers to the primary key of another table, establishing a link between the two tables.
Is it helpful?
Add Comment
View Comments
Ques 13. Write a SQL query to count the number of rows in a table.
SELECT COUNT(*) FROM table;
Is it helpful?
Add Comment
View Comments
Ques 14. Explain the concept of ACID properties in a database.
ACID (Atomicity, Consistency, Isolation, Durability) properties ensure the reliability of database transactions.
Is it helpful?
Add Comment
View Comments
Ques 15. Write a SQL query to find the third highest salary from an Employee table.
SELECT MAX(salary) FROM Employee WHERE salary < (SELECT MAX(salary) FROM Employee WHERE salary < (SELECT MAX(salary) FROM Employee));
Is it helpful?
Add Comment
View Comments
Most helpful rated by users:
- What is SQL?
- What is the difference between SQL and MySQL?
- What is a primary key?
- What is an index in a database?
- What is a foreign key?