Skip to content

Types of SQL Commands

Database management system (DBMS)-e SQL-er shob dhoroner kaj ebong instruction-ke tader uddesho onujayi ei category-gulote vag kora hoy:

  • DDL (Data Definition Language)
  • DML (Data Manipulation Language)
  • DQL (Data Query Language)
  • DCL (Data Control Language)
  • TCL (Transaction Control Language)

SQL commands are divided into five main categories based on their operational roles:


1. DDL (Data Definition Language)

  • Purpose: Used to define (āϏāĻ‚āĻœā§āĻžāĻžāϝāĻŧāĻŋāϤ āĻ•āϰāĻž), build, modify (āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻž), or destroy (āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻž) the database structure (āĻ•āĻžāĻ āĻžāĻŽā§‹) and schema.
  • Key Commands:
  • CREATE: Creates a new database or table from scratch.
  • ALTER: Modifies an existing (āĻŦāĻŋāĻĻā§āϝāĻŽāĻžāύ) table's structure (e.g., adding a new column or changing data types).
  • DROP: Deletes an entire (āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ) table or database along with its schema and records.
  • TRUNCATE: Rapidly purges (āĻ–āĻžāϞāĻŋ āĻ•āϰ⧇ āĻĢ⧇āϞ⧇) all rows from a table while keeping the structure intact (āĻ…āĻ•ā§āώāϤ/āĻ…āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāĻŋāϤ).

2. DML (Data Manipulation Language)

  • Purpose: Used to manipulate (āϰāĻĻāĻŦāĻĻāϞ āĻ•āϰāĻž) and manage the actual data records (instances) stored inside tables.
  • Key Commands:
  • INSERT: Adds new rows or records into an existing table.
  • UPDATE: Modifies existing data values within specified (āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ) rows.
  • DELETE: Removes specific rows based on defined criteria (āĻļāĻ°ā§āϤāĻžāĻŦāϞ⧀).

3. DQL (Data Query Language)

  • Purpose: Used to retrieve (āϖ⧁āρāĻœā§‡ āĻŦ⧇āϰ āĻ•āϰāĻž/āφāĻšāϰāĻŖ āĻ•āϰāĻž) and fetch relevant data from the database. Although some textbooks group this under DML, it is widely recognized as a distinct (āĻ¸ā§āĻŦāϤāĻ¨ā§āĻ¤ā§āϰ/āφāϞāĻžāĻĻāĻž) category.
  • Key Command:
  • SELECT: Extracts (āϤ⧁āϞ⧇ āφāύ⧇) and filters data matching specified conditions (e.g., SELECT * FROM Customers WHERE City = 'Dhaka';).
  • Note: Solves the file system problem of "Difficulty in Accessing Data."

4. DCL (Data Control Language)

  • Purpose: Controls user privileges (āĻŦāĻŋāĻļ⧇āώ āĻ…āϧāĻŋāĻ•āĻžāϰ) and access permissions (āĻ…āύ⧁āĻŽāϤāĻŋāϏāĻŽā§‚āĻš) to protect database security.
  • Key Commands:
  • GRANT: Gives a user permission to perform specific operations (āĻ•āĻžāĻ°ā§āϝāĻ•ā§āϰāĻŽ) on tables.
  • REVOKE: Withdraws (āĻĒā§āϰāĻ¤ā§āϝāĻžāĻšāĻžāϰ āĻ•āϰ⧇ āύ⧇āĻ“ā§ŸāĻž) or cancels permissions previously given to a user.
  • Note: Solves the file system problem of "Security Problems" by enforcing granular (āϏ⧁āĻ•ā§āĻˇā§āĻŽ/āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ) access limits.

5. TCL (Transaction Control Language)

  • Purpose: Manages transactions (āϞ⧇āύāĻĻ⧇āύāϏāĻŽā§‚āĻš/āĻ•āĻžāĻœā§‡āϰ āϧāĻžāĻĒ) in a database to ensure consistency (āϏāĻžāĻŽāĻžā§āϜāĻ¸ā§āϝāϤāĻž) and prevent data corruption.
  • Key Commands:
  • COMMIT: Permanently (āĻ¸ā§āĻĨāĻžāϝāĻŧā§€āĻ­āĻžāĻŦ⧇) saves all changes made during the current transaction.
  • ROLLBACK: Reverts (āĻĒā§‚āĻ°ā§āĻŦāĻžāĻŦāĻ¸ā§āĻĨāĻžāϝāĻŧ āĻĢāĻŋāϰāĻŋāϝāĻŧ⧇ āύ⧇āϝāĻŧ/Undo āĻ•āϰ⧇) data changes back to the previous state if an error or system crash occurs.
  • SAVEPOINT: Creates an intermediate (āĻŽāĻ§ā§āϝāĻŦāĻ°ā§āϤ⧀/āϏāĻžāĻŽāϝāĻŧāĻŋāĻ•) checkpoint inside a transaction to roll back partially.
  • Note: Solves the file system problem of "Atomicity of Updates" by preventing half-finished actions.

Summary Table

Category Full Form Primary Role Common Commands
DDL Data Definition Language Creates and alters (āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧇) database structures CREATE, ALTER, DROP, TRUNCATE
DML Data Manipulation Language Manages and edits stored records INSERT, UPDATE, DELETE
DQL Data Query Language Queries and retrieves (āφāĻšāϰāĻŖ āĻ•āϰ⧇) data SELECT
DCL Data Control Language Manages access permissions (āĻ…āύ⧁āĻŽāϤāĻŋ) and security GRANT, REVOKE
TCL Transaction Control Language Handles transaction safety and recovery (āĻĒ⧁āύāϰ⧁āĻĻā§āϧāĻžāϰ) COMMIT, ROLLBACK, SAVEPOINT