Types of SQL Commands
- Read
- Discuss
SQL Commands
SQL stands for Structured Query Language. Different types of SQL commands are the instructions that are used to communicate with a sequel database to perform tasks, functions, and queries with data. In this SQL tutorial for beginners, we’ll discuss some categories into which SQL commands are divided.
The SQL commands are divided into following 5 categories:

1. DDL (Data Definition Language)
DDL contains the SQL statements that are used to specify the database schema. It is used to create and modify the structure of database objects in the database and only works with descriptions of the database schema.
DDL changes the structure of the table like creating a table, deleting a table, altering a table, etc.,

CREATE:
It is used to create the database or its objects ( table etc).
DROP:
It is used to delete objects from the database.
ALTER:
It is used to alter the structure of the database.
TRUNCATE:
It is used to remove all records from a table, including all spaces allocated for the records.
2. DML (Data Manipulation Language)
As we know, DML contains the SQL commands that deal with the manipulation of data present in the database.
In other words, DML commands are used to modify the database. It is responsible for all forms of changes in the database but these changes are not auto-committed, which means it can’t permanently save all the changes in the database. They can be rolled back.

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.
3. DQL (Data Query Language)
Simply put, DQL contains the SQL commands that deal with performing queries on the data within schema objects. To clarify, DQL is used to fetch the data from the database. They can be rolled back.

SELECT:
This command allows getting the data out of the database to perform operations with it. A second temporary table is created and presented after a SELECT is performed on a table or tables.
4. DCL (Data Control Language)
Firstly, DCL contains the SQL commands that deal with the rights, permissions, and other controls of the database system. That is to say, DCL commands are used to grant and take back authority from any database user.

GRANT:
It is used to give user access privileges to a database
REVOKE:
It is used to take back permissions from the user.
5. TCL (Transaction Control Language)
Transactions group a set of tasks into a single execution unit. That is to say, TCL contains commands to manage transactions. However, TCL commands can only be used with DML commands like INSERT, DELETE and UPDATE only.
These operations are automatically committed in the database that’s why they cannot be used while creating tables or dropping them.

COMMIT:
COMMIT is used to save all the transactions to the database.
ROLLBACK:
ROLLBACK is used to undo transactions that have not already been saved to the database.
SAVEPOINT:
SAVEPOINT is used to roll the transaction back to a certain point without rolling back the entire transaction.
That’s everything you need to know about different types of SQL commands! Continue learning and play around with SQL logical operators.
One response to “Types of SQL Commands”
te
Leave a Reply
You must be logged in to post a comment.