Introduction to SQL Commands (DDL, DML,DQL, DCL, TCL)

Share via:

Introduction to SQL Commands (DDL, DML,DQL, DCL, TCL)

Beginner-Friendly Professional Documentation
1. SQL Basics & Command Categories
What is SQL?
SQL (Structured Query Language) is a standard language used to manage and interact with databases. Databases store data in the form of tables (rows and columns).
Example: A table called Students may contain columns like:
StudentID
● Name
● Age
● Course
SQL helps us perform tasks such as:
● Creating tables
● Adding data into tables
● Reading data from tables
● Updating and deleting records
● Controlling database security
● Managing transactions (commit/rollback)

 

2. Why SQL Commands Matter
SQL is made up of different commands, each used for a specific purpose.
For example:
● To create a table → CREATE
● To insert data → INSERT
● To read data → SELECT
● To allow permissions → GRANT

 

3. Categories of SQL Commands
SQL commands are grouped into five major categories:
Category
Full Form
Purpose
DDL
Data Definition Language
Defines database structure (tables, schema)
DML
Data Manipulation Language
Inserts, updates, deletes data
DQL
Data Query Language
Retrieves (queries) data
DCL
Data Control Language
Controls access/permissions
TCL
Transaction Control Language
Manages transactions (commit/rollback)
Concepts :
● DDL = Build structure
● DML = Change data
● DQL = Read data
● DCL = Control access
● TCL = Confirm/undo changes

 

4. DDL (Data Definition Language)
DDL commands are used to create and modify database structure.
That means you use DDL to create tables, change columns, and remove tables.
Key DDL Commands:
● CREATE
● ALTER
● DROP
● TRUNCATE
3.1.CREATE: Used to create a new table.

1.1.ALTER: Used to modify an existing table.
Example: Add a new column:

1.3.DROP: Used to completely delete a table.

1.1. TRUNCATE: Deletes all rows inside a table but keeps the table structure.

Summary of DDL:
Command
Action
CREATE
Creates tables/objects
ALTER
Modifies structure
DROP
Deletes object/table fully
TRUNCATE
Deletes all rows but keeps table

 

5. DML (Data Manipulation Language)
DML commands are used to work with the data inside tables.
Key DML Commands:
● INSERT
● UPDATE
● DELETE
3.2.INSERT: Adds new data into a table.

3.3.UPDATE: Updates existing records.

3.4.DELETE: Deletes specific records.

 

6. DQL (Data Query Language)

DQL is used to retrieve (read) data from the database.

Key DQL Command:
SELECT
3.5.SELECT: Fetch data from a table.

Summary of DML & DQL:
Categor y
Focus
Commands
DML
Modify data
INSERT, UPDATE, DELETE
DQL
Retrieve data
SELECT
 

 

7. TCL (Transaction Control Language)
TCL commands are used to manage transactions.
What is a Transaction?
A transaction is a group of SQL operations
Key TCL Commands:
COMMIT
ROLLBACK
SAVEPOINT
7.1.COMMIT: Saves the changes permanently.

7.2.ROLLBACK: Undo changes (only possible before commit).

7.3.SAVEPOINT: Creates a point where you can rollback partially.

 

8. DCL (Data Control Language)
DCL is used to manage permissions and security.
Key DCL Commands:
GRANT
REVOKE
3.6.GRANT: Gives permission.

3.7.REVOKE: Removes permission.

 

9. Final Comparison Table
Type
Used For
Example Commands
DDL
Structure creation/modification
CREATE, ALTER, DROP, TRUNCATE
DML
Changing data
INSERT, UPDATE, DELETE
DQL
Querying/reading data
SELECT
TCL
Transaction handling
COMMIT, ROLLBACK, SAVEPOINT
DCL
Access control/security
GRANT, REVOKE
 
Conclusion
DDL builds database structure
DML changes table data
DQL reads data
TCL controls transaction safety
DCL ensures security and permission control
This makes SQL powerful for real-world applications like:
Banking systems
Employee databases
College record systems
E-commerce websites

 

Author    : Khaja Shaik

LinkedIn  : http://linkedin.com/in/shaik-khajask

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates.

KTExperts is always active on social media platforms.

Facebook  : https://www.facebook.com/ktexperts

LinkedIn    : https://www.linkedin.com/company/ktexperts/

Twitter       : https://twitter.com/ktexpertsadmin

YouTube   :  https://www.youtube.com/c/ktexperts

Instagram  : https://www.instagram.com/knowledgesharingplatform

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment