What is the Difference Between DDL and DML?

🆚 Go to Comparative Table 🆚

The main difference between DDL and DML lies in their purpose and the operations they perform on a database.

DDL (Data Definition Language) deals with the structure of the data and is used to create and modify database objects like tables, indexes, views, and constraints. It defines the structure or schema of the database and helps in defining some constraints as well. Basic commands in DDL include CREATE, ALTER, DROP, RENAME, and TRUNCATE.

DML (Data Manipulation Language) is used to manipulate the data within the database, such as inserting, updating, and deleting data. It allows you to add, retrieve, or update the data. Basic commands in DML include INSERT, UPDATE, MERGE, and DELETE. DML statements alter the data that is stored in the database, not the database's structure.

In summary:

  • DDL is used to define the structure of a database.
  • DML is used to manipulate the data within the database.

Comparative Table: DDL vs DML

Here is a table summarizing the differences between Data Definition Language (DDL) and Data Manipulation Language (DML):

Property DDL DML
Full Form Data Definition Language Data Manipulation Language
Purpose Used to create and modify database objects like tables, indexes, views, and constraints. Used to perform operations on the data within those database objects.
Commands CREATE, ALTER, DROP, RENAME, etc.. INSERT, UPDATE, DELETE, MERGE, etc..
Table Affected DDL statements affect the entire table. DML commands affect one or more rows.
Rollback DDL statements cannot be rolled back. DML commands can be rolled back.
Where Clause DDL does not use the WHERE clause in its statement. DML uses the WHERE clause in its statement.
Classification DDL is not further classified. DML is classified into Procedural and Non-Procedural DML.

DDL is used to define the structure of a database, while DML is used to manipulate the data within the database. DDL commands are used to create and modify database objects like tables, indexes, views, and constraints, whereas DML commands are used to insert, update, and delete data within those objects.