DML Commands in SQL
An Introduction to SQL and its Data
Manipulation Language Commands
What is SQL?
• SQL (Structured Query Language) is a standard
programming language used to manage and
manipulate relational databases.
• - Used for querying, updating, and managing
data
• - Interacts with relational database systems
like MySQL, PostgreSQL, SQL Server, etc.
What is DML?
• DML stands for Data Manipulation Language.
• It is a subset of SQL used to insert, update,
delete, and retrieve data from a database.
• DML does not define the structure of data but
manipulates it.
INSERT Command
• Used to add new records to a table.
• Syntax:
• INSERT INTO table_name (column1,
column2, ...)
• VALUES (value1, value2, ...);
UPDATE Command
• Used to modify existing records in a table.
• Syntax:
• UPDATE table_name
• SET column1 = value1, column2 = value2, ...
• WHERE condition;
DELETE Command
• Used to remove records from a table.
• Syntax:
• DELETE FROM table_name
• WHERE condition;
SELECT Command
• Used to retrieve data from a database.
• Syntax:
• SELECT column1, column2, ...
• FROM table_name
• WHERE condition;
DML Commands: Example
• Consider a table named Employees (id, name,
salary):
• INSERT:
• INSERT INTO Employees (id, name, salary)
VALUES (1, 'Alice', 50000);
• SELECT:
• SELECT * FROM Employees;
DML Example with 10 Entries
• Table: Employees (id, name, salary)
• INSERT INTO Employees (id, name, salary)
VALUES
• (1, 'Alice', 50000), (2, 'Bob', 52000), (3,
'Charlie', 51000),
• (4, 'David', 53000), (5, 'Eva', 54000), (6, 'Frank',
50000),
• (7, 'Grace', 55000), (8, 'Helen', 56000), (9, 'Ivy',
57000),