SQL|DDL, DML and DCL commands

Data Definition Language :- DDL is a past of SQL, which consists of the commands that used to define define database schema, and used to create and modify the structure of database object in database. There are following DDL commands used in database.

  • Create command :- This command used to create database and its object like table,index, views and function. Syntax:

    CREATE TABLE table_name (column_name (data_type));

  • Alter command :- This command used to alter the structure of database. Syntax:

    ALTER TABLE <table name> [option];

  • Drop command :- This command used to delete object from the database. Syntax:

    DROP TABLE <table name>;

  • Rename command :- This command used to rename an object. Syntax:RENAME TABLE

    <old table name> <new table name>;

Data Manipulation Language :- DML is a part of SQL, which deals with the data manipulation, and include common SQL statements. Such as Select, Insert, Update, Delete etc.

  • Select command :- This command used to retrieve data from a database. Syntax:

    SELECT*FROM STUDENT;

  • Insert command :- This command used to insert data into the table. Syntax:

    INSERT into <table name> VALUES (<value 1>,<value 2>,….);

  • Update command :- This command used to update data in database. Syntax:

    UPDATE <table name> set <column name=new column value>[WHERE <condition>];

  • Delete command :- This command used to delete records from the database table. Syntax:

    DELETE FROM <table name> WHERE <condition>;

Data Control language :- DCL is a part of SQL, which allows to control the database system. It contains commands like GRANT and REVOKE.

  • GRANT command :- This command allow user’s access privileges to database. Syntax:

    GRANT <object_privileges> ON <object_name> TO <user_name> [with GRANT option];

  • REVOKE command :- Withdraw user’s access privileges given by using the GRANT command. Syntax:

    REVOKE <object_privileges> ON <object_name> FROM <user_name>;