Top 50 Basic Level SQL Interview Questions – Beginners Guide

Q1. What is SQL?

Answer:
SQL (Structured Query Language) is the standard language used to communicate with relational databases. It is used to create, retrieve, update, and delete data.


Q2. What are the different types of SQL commands?

Answer:
SQL commands are classified into:

  • DDL (Data Definition Language): CREATE, ALTER, DROP

  • DML (Data Manipulation Language): SELECT, INSERT, UPDATE, DELETE

  • DCL (Data Control Language): GRANT, REVOKE

  • TCL (Transaction Control Language): COMMIT, ROLLBACK, SAVEPOINT


Q3. What is a Database?

Answer:
A database is an organized collection of data stored electronically. Databases allow efficient access, management, and updating of data.

Example:
MySQL, SQL Server, Oracle Database.


Q4. What is a Table in SQL?

Answer:
A table is a collection of related data organized into rows and columns. Each table represents an entity.

Example:
A Students table may have columns like StudentID, Name, Age.

Syntax :

CREATE TABLE Students (
StudentID INT,
Name VARCHAR(50),
Age INT
);


Q5. What is a Primary Key?

Answer:
A Primary Key is a column (or a set of columns) that uniquely identifies each record in a table. It cannot contain NULL values.

Example:

CREATE TABLE Employees (
EmpID INT PRIMARY KEY,
Name VARCHAR(50)
);


Q6. What is a Foreign Key?

Answer:
A Foreign Key is a field in a table that refers to the Primary Key in another table. It creates a relationship between two tables.

Example:

CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
EmpID INT,
FOREIGN KEY (EmpID) REFERENCES Employees(EmpID)
);


Q7. What is a Unique Key?

Answer:
A Unique Key ensures that all values in a column are different. Unlike Primary Key, it can accept one NULL value.

Example:

CREATE TABLE Customers (
CustomerID INT UNIQUE,
Email VARCHAR(50) UNIQUE
);


Q8. What is the difference between Primary Key and Unique Key?

Answer:

Primary Key Unique Key
Cannot be NULL Can have one NULL
Only one Primary Key per table Multiple Unique Keys allowed
Ensures row uniqueness Ensures column uniqueness

Q9. What is a NULL value in SQL?

Answer:
NULL represents missing or unknown data in SQL. It is not the same as 0 or an empty string.

Example:

INSERT INTO Students (StudentID, Name, Age) VALUES (1, ‘John’, NULL);


Q10. What is the difference between NULL and 0?

Answer:

  • NULL means “no value” or “unknown.”

  • 0 is a definite numeric value.

Example:
A student’s age being NULL means we don’t know it. Age 0 means it’s set to zero.

Page : 1 2 3 4 5

Top 50 Intermediate SQL Interview Questions You Must Practice [With Examples]

Top 50 Advanced SQL Questions asked in Top Companies (with Answers + Examples)