Types of SQL commands
Types of SQL commands
SQL (Structured Query Language) commands are used to perform a variety of tasks on the database instance. SQL commands can be classified into different categories based on their functionality.
SQL commands are categorized into several types based on their functionality. SQL commands can be broadly classified into the following categories:
- DDL
- DML
- DQL
- DCL
- TCL
DDL
DDL stands for Data Definition Language. These commands define the structure of the database objects like tables, schemas, indexes, etc. DDL commands are used to create modify, and drop the structure of database objects. Examples of DDL statements are:
- CREATE – Creates a new table or database.
-
ALTER – Modifies an existing database object.
-
DROP – Deletes an existing database object.
- RENAME – Renames the database object.
-
TRUNCATE – Removes all records from a table, but not the structure.
DML
DML stands for Data Manipulation Language. DML commands are used to store, modify, and delete data in the database. These commands are used to manipulate data stored in the database. Examples of DML statements are :
- SELECT – Retrieves data from the database.
-
INSERT – Adds new data into a table.
-
UPDATE – Modifies existing data in a table.
-
DELETE – Removes data from a table.
DQL
DQL stands for Data Query Language. DQL command is used to retrieve data from the database. Example of DQL statement is the SELECT command. This category includes commands focused only on querying data.
-
SELECT – Although listed in DML, it’s often separately classified under DQL due to its read-only nature.
DCL
DCL stands for Data Control Language. DCL commands are used for specifying permissions, access control and providing security to database objects. These commands are used to control access to data in the database.
Examples of DCL statements are:
- GRANT – Gives privileges to users.
-
REVOKE – Removes privileges from users.
TCL
TCL stands for Transaction Control Language. A transaction is a set of one ore more SQL commands that change data in the Oracle database. TCL commands are used for managing changes affecting the data in the database.
These commands manage transactions in the database to ensure data integrity. Examples of TCL statements are:
- COMMIT – Saves the changes made by a transaction.
-
ROLLBACK – Reverts the changes made by a transaction.
-
SAVEPOINT – Sets a point within a transaction to which you can roll back later.
-
SET TRANSACTION – Sets the characteristics of the transaction.
Oracle Database Tutorials on this website: