What are the main differences between DML vs DDL?

The main difference between DML vs DDL is – one for managing data in database and other for define database. DML stands for Data Manipulation Language and DDL stands for Data Definition Language.

    1. DML statements are used to manage the data in a database just like insert, update, delete etc.
      insert into table(col1, col2, col3) value(val1, val2, val3)
    2. DDL statements are used to create and define database structure just like create, alter, drop etc.
      create table tablename (col1 datatype, col2 datatype, col3 datatype)
    3. DML statements work with rows of data in table. For example, insert will create one or more rows in a table, where DDL works on database objects like table or views etc. For example, create will create a new object of table or view or procedure etc.
    4. Most of the DML support where clause and having clause for filtering data and order by and group by functions. But DDL does not support these functions.
    5. Transactions can be applied to DML statements. Which means, COMMIT and ROLLBACK are supported in DML statements. But DDL does not support Transactions. Which means once a table is created it cannot be roll backed. It need another DDL statement of DROP to remove the table from database.
    6. DDL statements cannot fire any triggers. But DML can fire triggers.

Leave a Reply

%d bloggers like this: