QL is not just one language — it’s a collection of sub-languages categorized by their purpose.


1️⃣ DDL — Data Definition Language

Used to define or change the structure of database objects (like tables, schemas, indexes).

Common DDL Commands:

Command Description
CREATE Create new database objects (tables, views, indexes).
ALTER Modify an existing database object.
DROP Delete an object permanently.
TRUNCATE Delete all records from a table but keep structure.
RENAME Rename an existing table or column.

Example:

-- Create a table
CREATE TABLE Employees (
  emp_id SERIAL PRIMARY KEY,
  emp_name VARCHAR(50),
  salary NUMERIC(10,2),
  department VARCHAR(30)
);

-- Add a new column
ALTER TABLE Employees ADD COLUMN joining_date DATE;

-- Delete all rows but keep table structure
TRUNCATE TABLE Employees;

-- Drop the table permanently
DROP TABLE Employees;

🧩 Key Point:


2️⃣ DML — Data Manipulation Language

Used to manipulate data inside tables (insert, update, delete records).

Common DML Commands:

Command Description
INSERT Add new data.
UPDATE Modify existing data.
DELETE Remove specific data.

Example:

-- Insert new record
INSERT INTO Employees (emp_name, salary, department)
VALUES ('Abhishek', 80000, 'Engineering');

-- Update salary
UPDATE Employees SET salary = salary + 5000 WHERE emp_id = 1;

-- Delete record
DELETE FROM Employees WHERE emp_name = 'John';

💡 Transaction Note:

DML commands can be rolled back — they are not auto-committed.