Skip to content
MasterData
  • Home
  • All Courses
  • Blog
    • Apache Spark
Start Learning
Start Learning
MasterData
  • Home
  • All Courses
  • Blog
    • Apache Spark

Apache Airflow

2
  • Apache Airflow: What, Why, and How?
  • How to Deploy Apache Airflow on Kubernetes

Apache Iceberg

3
  • [01] – Introduction to Apache Iceberg
  • [02] – Getting Started with Apache Iceberg
  • [03] – Apache Iceberg Architecture

Apache Spark

4
  • [00] – Apache Spark By Example Course
  • [01] – What is Apache Spark?
  • [02] – Installing Apache Spark Locally
  • [03] – Deploy Apache Spark with Kubernetes (K8s)

Data Build Tool (DBT)

7
  • [00] – dbt by Example Course
  • [01] – dbt : What it is, Why and How?
  • [02] – Install dbt in local
  • [03] – Explore dbt Models
  • [04] – Sources in dbt
  • [05] – Seeds in dbt
  • [06] – Jinja Templates and Macros in dbt

SQL - Advanced

2
  • [02] – View vs Materialized View
  • [03] – Window function in SQL

SQL - Basics

1
  • 02 – Understanding SQL Operations (DML, DDL, DCL, and TCL)

SQL - Intermediate

1
  • SQL Joins: Understanding INNER, LEFT, RIGHT, and FULL Joins
  • Home
  • Docs
  • SQL
  • SQL - Basics
  • 02 – Understanding SQL Operations (DML, DDL, DCL, and TCL)
View Categories

02 – Understanding SQL Operations (DML, DDL, DCL, and TCL)

kerrache.massipssa

Structured Query Language (SQL) is the backbone of database management and serves as a critical tool for interacting with relational databases. To perform various operations on a database, SQL is categorized into four main types of commands:

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

Understanding these categories is essential for efficient database management. Let’s explore each in detail.

Data Definition Language (DDL) #

DDL commands deal with the structure and schema of a database. These commands are used to define, modify, or delete database objects such as tables, indexes, and schemas.

  • CREATE: Used to create database objects like tables, indexes, or databases.
CREATE TABLE employees ( 
    id INT PRIMARY KEY,
    name VARCHAR(100),
    department VARCHAR(50),
    salary DECIMAL(10, 2)
);
  • ALTER: Used to modify existing database objects, such as adding or removing columns from a table.
ALTER TABLE employees ADD COLUMN hire_date DATE;
  • DROP: Used to delete database objects completely.
DROP TABLE employees;
  • TRUNCATE: Deletes all records from a table but retains the table structure for future use.
TRUNCATE TABLE employees;

Data Manipulation Language (DML) #

DML commands are used to retrieve, insert, update, and delete data in a database. These commands operate on the data within the database tables.

  • SELECT: Retrieves data from the database.
SELECT name, department FROM employees WHERE salary > 50000;
  • INSERT: Adds new records to a table.
INSERT INTO employees (id, name, department, salary, hire_date) VALUES (1, 'John Doe', 'Engineering', 75000, '2023-01-15');
  • UPDATE: Modifies existing records in a table.
UPDATE employees SET salary = 80000 WHERE id = 1;
  • DELETE: Removes specific records from a table.
 DELETE FROM employees WHERE id = 1;

Data Control Language (DCL) #

DCL commands manage permissions and access to the database. These commands are primarily used by database administrators to enforce security.

  • GRANT: Provides specific privileges to users or roles.
GRANT SELECT, INSERT ON employees TO user1;
  • REVOKE: Removes previously granted permissions.
REVOKE INSERT ON employees FROM user1;

Transaction Control Language (TCL) #

TCL commands manage transactions in a database. Transactions ensure that a series of operations are executed as a single unit of work, maintaining data consistency and integrity.

  • COMMIT: Saves all changes made during the transaction.
COMMIT;
  • ROLLBACK: Undoes all changes made during the current transaction.
ROLLBACK;
  • SAVEPOINT: Creates a point within a transaction to which you can later roll back.
SAVEPOINT sp1;
  • SET TRANSACTION: Defines properties for a transaction, such as isolation level.
 SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

Summary Table of SQL Commands #

CategoryCommandsDescription
DDLCREATE, ALTER, DROP, TRUNCATEDefines or modifies database structures
DMLSELECT, INSERT, UPDATE, DELETEOperates on the data within the database
DCLGRANT, REVOKEManages user access and permissions
TCLCOMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTIONControls transactions in the database

Conclusion #

By mastering DDL, DML, DCL, and TCL commands, you gain full control over your database, from defining its structure to managing its data and access permissions. Whether you are a database administrator or a developer, understanding these categories will help you write efficient and secure SQL scripts that ensure optimal database performance.

Updated on March 8, 2025

Leave a Reply Cancel reply

You must be logged in to post a comment.

Table of Contents
  • Data Definition Language (DDL)
  • Data Manipulation Language (DML)
  • Data Control Language (DCL)
  • Transaction Control Language (TCL)
  • Summary Table of SQL Commands
  • Conclusion

Copyright © 2025 MasterData

Powered by MasterData

Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}