What is SQL Commands | DDL, DML, DCL, TCL, DQL

SQL stands for Structured Query Language. SQL commands are the instructions used to interact with a database to perform tasks, functions, and queries with data. SQL commands can be used to search the database and to do other functions like creating tables, adding data to tables, modifying data, and dropping tables. 
By using SQL command we can fetch the required data from the database. Also we can create, modify, update & delete the data from the database. SQL uses certain commands like Create, Drop, Insert, etc. to carry out the required tasks.

Types of SQL Commands:
DDL, DML, DCL, TCL, and DQL.

SQL Commands


DDL (Data Definition Language):
Data Definition Language used to define the database schema. DDL deals with the structure of the table like creating a table, deleting a table, altering a table, etc.
DDL is a set of SQL commands used to create, modify, and delete database structures.

List of DDL commands:
CREATE: This command is used to create the database or its objects (like table, index, function, views, store procedure, and triggers).
DROP: This command is used to delete objects from the database.
ALTER: This is used to alter the structure of the database.
TRUNCATE: This is used to remove all records from a table, including all spaces allocated for the records to be removed.


DML (Data Manipulation Language):
Data Manipulation Language deals with modification/manipulation of the data present in the database. Using the DML command we can insert, update or delete the data from the database.
The command of DML is not auto-committed that means it cant permanently save all the changes in the database. They can be rolled back.

List of DML commands:
INSERT : It is used to insert data into a table.
UPDATE: It is used to update existing data within a table.
DELETE : It is used to delete records from a database table.


DCL (Data Control Language):
Data Control Language mainly deal with the rights, permissions, and other controls of the database system by using commands such as GRANT and REVOKE.
Data Control Language is used to manage roles, permissions, grant and revoke authority on users of the database.

List of DCL commands:
GRANT: This command gives users access privileges to the database.
REVOKE: This command withdraws the user’s access privileges given by using the GRANT command.


TCL (Transaction Control Language):
Transaction Control Language used with DML command like INSERT, DELETE and UPDATE to commit or revert the changes. TCL manages the issues and matters related to the transactions in any database. They are used to rollback or commit the changes in the database.

List of DCL commands:
Commit: Commit command is used to save all the transactions to the database.
Rollback: Rollback command is used to undo transactions that have not already been saved to the database.


DQL (Data Query Language):
Data Query Language used to fetch the data from the database by using the SELECT statement. The purpose of the DQL Command is to get some schema relation based on the query passed to it.

List of DQL commands:
SELECT: It is used to retrieve data from the database.

No comments: