Structured Query Language(SQL) as we all know is the database language by the use of which we can perform certain operations on the existing database and also we can use this language to create a database. SQL uses certain commands like Create, Drop, Insert etc. to carry out the required tasks.
These SQL commands are mainly categorized into four categories as discussed below:
- DDL(Data Definition Language) : DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema. It simply deals with descriptions of the database schema and is used to create and modify the structure of database objects in database.
Examples of DDL commands:
- CREATE – is used to create the database or its objects (like table, index, function, views, store procedure and triggers).
- DROP – is used to delete objects from the database.
- ALTER-is used to alter the structure of the database.
- TRUNCATE–is used to remove all records from a table, including all spaces allocated for the records are removed.
- COMMENT –is used to add comments to the data dictionary.
- RENAME –is used to rename an object existing in the database.
- DML(Data Manipulation Language) : The SQL commands that deals with the manipulation of data present in database belong to DML or Data Manipulation Language and this includes most of the SQL statements.
Examples of DML:
- DCL(Data Control Language) : DCL includes commands such as GRANT and REVOKE which mainly deals with the rights, permissions and other controls of the database system.
Examples of DCL commands:
- GRANT-gives user’s access privileges to database.
- REVOKE-withdraw user’s access privileges given by using the GRANT command.
- TCL(transaction Control Language) : TCL commands deals with the transaction within the database.
Examples of TCL commands:
- COMMIT– commits a Transaction.
- ROLLBACK– rollbacks a transaction in case of any error occurs.
- SAVEPOINT–sets a savepoint within a transaction.
- SET TRANSACTION–specify characteristics for the transaction.
This article is contributed by Dimpy Varshni. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- SELECT INTO statement in SQL
- Pivot and Unpivot in SQL
- Common error in Group By
- Categories of SQL Functions
- Query to find 2nd largest value in a column in Table
- Comparisons between Oracle vs SQL Server
- SQL vs NoSQL: Which one is better to use?
- What are the Best Ways to Write a SQL Query?
- Mathematical functions in MySQL
- MySQL | Ranking Functions
- MySQL | DEFAULT() Function
- MySQL | Recursive CTE (Common Table Expressions)
- MySQL | Group_CONCAT() Function
- MySQL | LEAD() and LAG() Function