DDL & DML
DDL is Data Definition Language that is used to define data
structures. For example: create table, alter table are instructions in
SQL. DML is Data Manipulation Language that is used to manipulate
data itself. For example: insert, update, and delete are instructions in
SQL.
The difference between DDL and DML:
DDL DML
It stands for Data Definition It stands for Data Manipulation
Language. Language.
It is used to create database
It is used to add, retrieve or
schema and can be used to define
update the data.
some constraints as well.
It add or updates the row of the
It basically defines the column
table. These rows are called
(Attributes) of the table.
tuple.
It is further classified
It doesn’t have any further
into Procedural and Non-
classification.
Procedural DML.
Basic command present in DDL BASIC command present in
are CREATE, DROP, RENAME, DML are UPDATE, INSERT,
ALTER etc. MERGE etc.
DDL does not use WHERE While DML uses WHERE
clause in its statement. clause in its statement.
DDL DML
DDL is used to define the DML is used to manipulate the
structure of a database. data within the database.
DDL is used to create and modify DML is used to perform
database objects like tables, operations on the data within
indexes, views, and constraints. those database objects.
DDL statements are typically DML statements are frequently
executed less frequently than executed to manipulate and
DML statements. query data.
DDL statements are typically DML statements are typically
executed by database executed by application
administrators. developers or end-users.
DDL statements are not used to DML statements are used to
manipulate data directly. manipulate data directly.
DDL statements do not change the DML statements change the
contents of the database. contents of the database.
Examples of DDL commands:
CREATE TABLE, ALTER Examples of DML commands:
TABLE, DROP TABLE, SELECT, INSERT, UPDATE,
TRUNCATE TABLE, and DELETE, and MERGE.
RENAME TABLE.