1. Data Definition Language (DDL):
DDL queries are used to define and modify the structure of a database. The following SQL commands are used for DDL:- CREATE: Creates a database, table, schema, index or any other object in the database.
- DROP: Drops tables, views, procedures, indexes and other database objects.
- ALTER: Alters the definition of database objects like tables, views, procedures, and indexes.
- TRUNCATE: Removes all data from a table.
- ADD COLUMN: Adds a column to an existing table.
- RENAME: Renames a table or a column.
2. Data Manipulation Language (DML):
DML queries are used to manipulate data in a database. The following SQL commands are used for DML:- SELECT: Retrieves data from one or more tables.
- INSERT: Inserts data or records into a table.
- UPDATE: Updates the values of records in a table.
- DELETE: Deletes records from a table.
- MERGE: Combines data from two or more tables.
3. Data Control Language (DCL):
DCL queries manage the access rights and permission control of the database. The following SQL commands are used for DCL:- GRANT: Grants access rights to a user or a group of users for a specific object in the database.
- REVOKE: Withdraws permission from users or groups of users for a specific object in the database.
4. Transaction Control Language (TCL):
TCL queries manage transactions in a database. The following SQL commands are used for TCL:- COMMIT: Makes the changes made in a transaction permanent.
- ROLLBACK: Undoes the changes made in a transaction and restores the database to its previous state.
- SAVEPOINT: Creates a savepoint in a transaction that can be rolled back to.
- SET TRANSACTION: Sets the characteristics of a transaction.
In conclusion, SQL queries are divided into four subsets based on their functionality: Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL). DDL queries define and modify the structure of a database, DML queries manipulate data in a database, DCL queries manage access rights and permission control, and TCL queries manage transactions in a database. Understanding these subsets is crucial for effective database management using SQL.