πŸš€ Day 7: Types of SQL commands

RishithaRishitha
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

CategoryPurposeExamples
DDLData Definition LanguageCREATE, ALTER, DROP
DMLData Manipulation LanguageINSERT, UPDATE, DELETE
DQLData Query LanguageSELECT
DCLData Control LanguageGRANT, REVOKE
TCLTransaction Control LanguageCOMMIT, ROLLBACK, SAVEPOINT

DDL – Data Definition Language

DDL commands define and modify the structure of the database objects like tables, schemas, and indexes.

CommandDescription
CREATECreates new databases, tables, views, indexes
ALTERModifies an existing table (add/remove columns)
DROPDeletes a table or database
TRUNCATERemoves all data from a table but keeps the structure

DML – Data Manipulation Language

DML commands are used to modify the data inside tables.

CommandDescription
INSERTAdds new data
UPDATEModifies existing data
DELETERemoves data from a table

DQL – Data Query Language

DQL includes the SELECT statement, used to query data from one or more tables.

CommandDescription
SELECTRetrieves data from a table

DCL – Data Control Language

DCL deals with permissions and access control.

CommandDescription
GRANTGives user access privileges
REVOKERemoves user access privileges

TCL – Transaction Control Language

TCL commands manage changes made by DML statements. They ensure data integrity and consistency in transactions.

COMMITSaves all changes made in the current transaction
ROLLBACKUndoes changes since the last COMMIT
SAVEPOINTSets 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.

Written by

Rishitha
Rishitha