π Day 7: Types of SQL commands

2 min read

Welcome back to Day 7 of the SQL tutorial series! π
Today, letβs explore the 5 main types of SQL commands β this will help you organize your learning and know whyyouβre writing a specific SQL statement.
π The 5 Types of SQL Commands
Category | Purpose | Examples |
DDL | Data Definition Language | CREATE, ALTER, DROP |
DML | Data Manipulation Language | INSERT, UPDATE, DELETE |
DQL | Data Query Language | SELECT |
DCL | Data Control Language | GRANT, REVOKE |
TCL | Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT |
DDL β Data Definition Language
DDL commands define and modify the structure of the database objects like tables, schemas, and indexes.
Command | Description |
CREATE | Creates new databases, tables, views, indexes |
ALTER | Modifies an existing table (add/remove columns) |
DROP | Deletes a table or database |
TRUNCATE | Removes all data from a table but keeps the structure |
DML β Data Manipulation Language
DML commands are used to modify the data inside tables.
Command | Description |
INSERT | Adds new data |
UPDATE | Modifies existing data |
DELETE | Removes data from a table |
DQL β Data Query Language
DQL includes the SELECT statement, used to query data from one or more tables.
Command | Description |
SELECT | Retrieves data from a table |
DCL β Data Control Language
DCL deals with permissions and access control.
Command | Description |
GRANT | Gives user access privileges |
REVOKE | Removes user access privileges |
TCL β Transaction Control Language
TCL commands manage changes made by DML statements. They ensure data integrity and consistency in transactions.
COMMIT | Saves all changes made in the current transaction |
ROLLBACK | Undoes changes since the last COMMIT |
SAVEPOINT | Sets a point to rollback to later |
0
Subscribe to my newsletter
Read articles from Rishitha directly inside your inbox. Subscribe to the newsletter, and don't miss out.
SQL ServerSQLMySQLRDBMSDBMSsql Queriesfrom beginner to advanced Beginner-friendlyDDLDQLDMLdcl#SQLtutorial
Written by
