SQL Interview Questions

  1. Can you explain the difference between a primary key and a foreign key in a relational database?
  2. How do you design a database schema for a new application?
  3. How do you write a SQL query to select specific columns and rows from a table?
  4. Can you explain the difference between a left join and a right join?
  5. How do you write a SQL query to update or delete specific rows in a table?
  6. Can you explain how indexes work in a relational database and why they are important?
  7. How do you write a SQL query to find duplicate rows in a table?
  8. Can you explain how transactions work in SQL and how they are used to ensure data consistency?
  9. How do you write a SQL query to retrieve data from multiple tables using a join?
  10. Can you explain the difference between a subquery and a join?
  11. How do you write a SQL query to create a new table and insert data into it?
  12. Can you explain how views work in SQL and when they should be used?
  13. How do you write a SQL query to group data by certain columns and calculate aggregate functions?
  14. Can you explain the difference between a clustered and non-clustered index?
  15. How do you optimize a slow SQL query?
  16. Can you explain the difference between SQL and NoSQL databases?
  17. How do you write a SQL query to create a stored procedure?
  18. Can you explain the difference between a temporary table and a table variable?
  19. How do you write a SQL query to create a trigger?
  20. Can you explain the difference between a union and a union all in SQL?