DDL, DML and DCL statements in MySQL with examples


SQL (Structured Query Language) is the language used to access the data in a database. By using SQL, we can retrieve data from the database, we can modify or delete existing data, we can also create new data in the database. Not only the data, but using SQL we can work on the database objects also by creating new objects and modifying or deleting existing database objects. We can write SQL statements and execute them to perform database operations. There are various types of SQL commands - DDL, DML, DCL, etc. Let us discuss them here.

DDL (Data Definition Language)

DDL commands are those which are used to work on the database objects. They do not deal with the data but the database objects like tables. DDL commands are used to create, alter, drop and rename tables or other objects in the database. Some examples are: CREATE TABLE, ALTER TABLE, DROP TABLE, RENAME TABLE etc.

DML (Data Manipulation Language)

These SQL commands are used to manipulate data in the database, like inserting, modifying, or deleting data. So, these commands are used on the data stored in the database or to create new data. Examples: INSERT, UPDATE, DELETE statements.

DQL (Data Query Language)

DQL statements are those that retrieve the data from the database. It can fetch the required data and display them on the screen. It is called DQL as these statements are used to query the database tables. Example: SELECT statement.

DCL (Data Control Language)

DCL commands deal with the access or permission to the data or database objects in the database. These are used to grant permission or revoke access to some tables. Examples are GRANT, REVOKE, etc.

TCL (Transaction Control Language)

There is one more category of SQL commands, called TCL. These are used for transactions. A transaction consists of one or more SQL statements. They work as groups. If all statements in a transaction are executed successfully the transaction is complete. If any of the statements fails, then the whole transaction fails. Examples are COMMIT and ROLLBACK.


SQL is required in almost all applications that interact with the database. We have discussed different categories of SQL commands in this topic. It is always good to know the type of SQL commands whenever you use it during project development.