Go Back

What are the differences between DDL, DML and DCL in SQL | developerIndian

5/8/2022
All Articles

#ddl and dml commands #dcl command #dcl in sql #sql_dml_ddl_tcl_dcl

What are the differences between DDL, DML and DCL in SQL | developerIndian

What are the differences between DDL, DML and DCL in SQL | developerIndian

  1. DDL represent for Data Definition Language. SQL queries like CREATE, ALTER, DROP and RENAME come under this.
    CREATE : to create objects in database
    ALTER : alters the structure of database
    DROP : delete objects from database
    RENAME : rename an objects
    
    Example of creation of table  Data Definition Language
    create table Developer
    (location char(20),
      languae char(15),
      Mark   numeric(12,2));
  2. DML represent for Data Manipulation Language. SQL queries like SELECT, INSERT and UPDATE come under this.
    SELECT: retrieve data from the database
    INSERT: insert data into a table
    UPDATE: update existing data within a table
    DELETE: deletes all records from a table, space for the records remain
    
    Example of creation of table Data Manipulation Language
    
    select location
     from developer
     where developer.location= 'india';
  3. TCL (Transaction Control Language) :Transaction Control Language commands are used to manage transactions in the database. it is represent commit ,rollback ,Save point 
    COMMIT: Commit command in sql is used to permanently save any transaction
                into the database .
    ROLLBACK: Rollback command restores the database to last committed state.
                It is also used with savepoint command to jump to a savepoint
                in a transaction.
    SAVEPOINT: Savepoint command in sql  is used to temporarily save a
               transaction so that you can rollback to that point 
               whenever necessary.
    Example of creation of table Data Manipulation Language
    mysql> COMMIT; 
    turn off commit 
    mysql> SET autocommit = 0;
    
  4. DCL represent  for Data Control Language. SQL queries like GRANT and REVOKE come under this.
    Example of creation of table Data Manipulation Language
    mysql> ROLLBACK;

Article