SQL Interview Questions
- What is SQL? SQL (Structured Query Language) is a programming language used for managing and manipulating relational databases. It is used for inserting, updating, and querying data stored in a database.
- What is a relational database? A relational database is a type of database that stores data in tables. These tables are related to each other through a common field, also known as a key. The most common type of relational database is SQL databases.
- What is a primary key? A primary key is a unique identifier for each row in a table. It is used to differentiate one row from another and is used to establish a link between tables in a relational database.
- What is a foreign key? A foreign key is a field in a table that is used to establish a link between two tables in a relational database. It is a reference to the primary key of another table.
- What is a join in SQL? A join is a SQL operator that combines rows from two or more tables based on a related column between them. There are several types of joins such as inner join, left join, right join and full outer join.
- What is a subquery in SQL? A subquery is a query that is nested inside another query. It is used to retrieve data that will be used in the main query.
- What is a view in SQL? A view in SQL is a virtual table that is based on the result of a SELECT statement. It does not store data itself, but instead references the data from the underlying tables.
- What is an index in SQL? An index in SQL is a database object that is used to speed up the retrieval of data from a table. It is similar to an index in a book and allows for faster searching and sorting of data.
- What is a stored procedure in SQL? A stored procedure in SQL is a precompiled set of SQL statements that can be executed with a single call. It is used to encapsulate a series of SQL statements, making it easier to manage and maintain the database.
- What is a trigger in SQL? A trigger in SQL is a set of instructions that are executed automatically in response to a specific event, such as the insertion, update or deletion of a record in a table. It is used to automatically enforce business rules or to perform additional tasks when data is changed in the database.