Last Updated: 09 November, 2025

MySQL DDL, DML, and DCL Statements Explained with Examples

Introduction

Understanding DDL, DML, and DCL in MySQL is essential for anyone learning SQL or working with databases. These SQL commands help you create, modify, and manage data effectively in a MySQL database. In this tutorial, you'll learn the types of SQL commands in MySQL with examples. 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)

DML statements 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 commands. 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.

Conclusion

In this tutorial, you learned about the types of SQL commands in MySQL — DDL, DML, DCL, DQL and TCL with examples. DDL statements define the database structure, DML commands handle data manipulation, DCL statements manage user permissions, DQL statements are for database queries and TCL commands are used to manage transactions. Understanding how these commands work helps you design, manage, and secure your MySQL databases effectively. I hope you now understand the difference between DDL, DML and DCL statements in MySQL.

Post a Comment

Save my Name and Email id for future comments