img
SQL

SQL is a programming language for managing relational databases. It handles data storage, retrieval, and manipulation efficiently.

Last updated on:- 12th June 2023


1.
What is SQL ?

SQL stands for Structured Query Language. It is a programming language used for managing and manipulating relational databases.

2.
What is a database ?

A database is a structured collection of data that is organized and managed for efficient retrieval and manipulation.

3.
What is a primary key in SQL ?

A primary key is a unique identifier for each record in a table. It ensures that each row can be uniquely identified and provides a way to enforce data integrity.

4.
What is a foreign key in SQL ?

A foreign key is a column or a set of columns in a table that refers to the primary key of another table. It establishes a relationship between the two tables.

5.
What is the difference between SQL and NoSQL databases ?

SQL databases are relational databases that store data in structured tables, while NoSQL databases are non-relational and store data in a flexible format like key-value pairs or JSON documents.

6.
What is the difference between the WHERE and HAVING clauses in SQL ?

The WHERE clause is used to filter rows based on a condition before grouping them, while the HAVING clause is used to filter groups based on a condition after the grouping is done.

7.
What is the difference between INNER JOIN and OUTER JOIN in SQL ?

INNER JOIN returns only the matching rows between two tables, while OUTER JOIN returns all rows from one table and the matching rows from the other table.

8.
Explain the ACID properties in SQL.

ACID stands for Atomicity, Consistency, Isolation, and Durability. These properties ensure that database transactions are reliable, consistent, and maintain data integrity.

9.
What is normalization in SQL ?

Normalization is the process of organizing data in a database to eliminate redundancy and dependency issues. It involves splitting data into multiple tables and defining relationships between them.

10.
What is a subquery in SQL ?

A subquery is a query nested within another query. It is used to retrieve data from one or more tables based on the result of another query.

11.
What is the difference between UNION and UNION ALL in SQL ?

UNION combines the result sets of two or more SELECT statements and removes duplicates, while UNION ALL combines the result sets without removing duplicates.

12.
What is a stored procedure in SQL ?

A stored procedure is a set of SQL statements that are stored in the database and can be executed multiple times. It helps improve performance, code reusability, and security.

13.
What is the difference between a view and a table in SQL ?

A table stores data physically in the database, while a view is a virtual table that is derived from one or more tables or views. Views provide a way to simplify complex queries and restrict access to data.

14.
Explain the GROUP BY clause in SQL.

The GROUP BY clause is used to group rows based on one or more columns. It is often used with aggregate functions like COUNT, SUM, AVG, etc., to perform calculations on grouped data.

15.
What is the purpose of the ORDER BY clause in SQL ?

The ORDER BY clause is used to sort the result set based on one or more columns in ascending or descending order. It helps in presenting data in a specific order.

16.
What is the difference between a unique key and a primary key in SQL ?

A primary key is a special type of unique key that uniquely identifies each record in a table and is automatically created when defining a table. A unique key ensures that a column or a set of columns has unique values but does not automatically define the record's identity.

17.
What is the purpose of the INDEX in SQL ?

An INDEX is a database structure that improves the speed of data retrieval operations. It allows the database engine to quickly locate specific rows based on the values in the indexed columns.

18.
What is the difference between DDL and DML in SQL ?

DDL (Data Definition Language) is used to define and modify the structure of database objects, such as tables, indexes, and views. DML (Data Manipulation Language) is used to manage and manipulate the data within those objects, such as inserting, updating, and deleting records.

19.
What is a self-join in SQL ?

A self-join is a join operation where a table is joined with itself. It is useful when a table has a hierarchical or recursive structure, and you need to retrieve related data from the same table.

20.
What are triggers in SQL ?

Triggers are special types of stored procedures that are automatically executed in response to specific events, such as INSERT, UPDATE, or DELETE operations on a table. They are used to enforce business rules, maintain data integrity, or perform additional actions based on the event.
img

"Embrace curiosity, unlock knowledge"

Copyright © 2023 - Some rights reserved

Made with

in INDIA