In this topic, we described about the below sections -
What is SQL Command?
SQL Commands are also called as SQL statements.
SQL commands are instructions to interact with relational databases. SQL can perform various tasks like create a table, add data to tables, delete the table, modify the table, set permission for users.
Types of SQL Commands
These commands can be classified into the following groups based on their nature as follows -
- DDL - Data Definition Language
- DML - Data Manipulation Language
- DCL - Data Control Language
- TCL - Transaction Control Language
- DQL - Data Query Language
Data Definition Language (DDL)
DDL is a short name for Data Definition Language. DDL deals with database schemas and descriptions. DDL also used to define that how the data resides in the database.
DDL also used to create, modify, and delete the database objects in the database. The modifications done on database objects are permanent.
Below table contains the list of DDL commands used in SQL –
|CREATE||Used to create the database and its objects like tables, views, indexes, functions, views, stored procedures, and triggers.|
|DROP||Used to delete the database and its objects from the database.|
|ALTER||Used to modify the database structure and its objects structure in the database.|
|TRUNCATE||Used to remove all the records from the table that includes all allocated space for the records.|
|COMMENT||Used to add comment to data dictionary|
|RENAME||Used to rename the database and its objects in the database.|
Data Query Language (DQL)
DQL is the short form of Data Query Language. DQL is used to query the database to retrieve the data from different database objects. DQL used to perform the data retrieval queries.
Below table contains the list of DQL commands used in SQL –
|SELECT||Used to retrieve the data from the database|
Data Manipulation Language (DML)
DML is the short form of the Data Manipulation Language. DML commands deals with the data modification in the database. The data modification includes inserting, updating, and deleting data in the database.
Below table contains the list of DML commands used in SQL –
|INSERT||Used to insert the rows into the table in the database.|
|UPDATE||Used to update the table data in the database.|
|DELETE||Used to delete the data from the table in the database.|
Data Control Language (DCL)
DCL is the short form of Data Control Language. DCL mainly deals with the access rights, permission to access database and controlling database. DCL commands used to control all privileges that are related to the database.
Below table contains the list of DCL commands used in SQL –
|GRANT||Gives access privileges to access the database.|
|REVOKE||Used to remove the privileges that are provided using GRANT statement.|
Transaction Control Language (TCL)
TCL is a short form of Transaction Control Language. TCL commands used to set the save points that plays a major role while updating or deleting the applied changes on the database. In TCL, the save points are set by using transactions.
Below table contains the list of TCL commands used in SQL –
|COMMIT||Commits the database changes till the point.|
|ROLLBACK||Reverts the changes till the point in case of any errors.|
|SAVEPOINT||Sets the Save point within the transaction.|
|SET TRANSACTION||Specify the characteristics of transaction.|