#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
SQL for Testers

Overview of DML , DDL, TCL,DCL

The Four SQL Command Categories

  • DDL (Data Definition Language): defines and modifies database structure — CREATE, ALTER, DROP, TRUNCATE, RENAME.
  • DML (Data Manipulation Language): manipulates the actual data within tables — INSERT, UPDATE, DELETE, MERGE.
  • TCL (Transaction Control Language): manages transactions — COMMIT, ROLLBACK, SAVEPOINT.
  • DCL (Data Control Language): manages access and permissions — GRANT, REVOKE.

Why the Distinction Matters

Understanding which category a statement belongs to clarifies its effect: DDL changes structure and auto-commits in most databases, DML changes data and can typically be rolled back until committed, and TCL explicitly controls when those changes become permanent.

All Four Categories in One Test-Setup Script

Seeing the categories side by side in a realistic script makes the difference clear. Here is how a tester might prepare a small orders table, load data, check access and clean up:

-- DDL: build the structure
CREATE TABLE orders (
    id        INT PRIMARY KEY,
    customer  VARCHAR(50) NOT NULL,
    amount    DECIMAL(10,2),
    status    VARCHAR(20) DEFAULT 'NEW'
);
ALTER TABLE orders ADD created_at TIMESTAMP;

-- DML: work with the data
INSERT INTO orders (id, customer, amount) VALUES (1, 'Neha', 1200.00), (2, 'Arjun', 450.50);
UPDATE orders SET status = 'SHIPPED' WHERE id = 1;
DELETE FROM orders WHERE amount < 500;

-- DQL: read the data (often grouped with DML)
SELECT id, customer, status FROM orders;

-- DCL: control who can do what
GRANT SELECT ON orders TO qa_readonly;
REVOKE INSERT, UPDATE ON orders FROM qa_readonly;

-- TCL: decide whether changes stay
COMMIT;

Some textbooks list SELECT under DML, while others give it a fifth category, DQL (Data Query Language). Both views are common, so you may see either in interviews or documentation.

Quick Comparison Table

CategoryWorks onCan be rolled back?Typical user
DDLTables, columns, indexes, viewsUsually not in MySQL and Oracle; often yes in PostgreSQL and SQL Server inside a transactionDevelopers, DBAs
DMLRows of dataYes, until committedApplications, testers
DCLUser and role permissionsDepends on the databaseDBAs, security teams
TCLThe current transactionIt is the rollback mechanismAnyone changing data

DELETE, TRUNCATE and DROP: a favourite interview question

CommandCategoryWhat it removesKey behaviour
DELETEDMLChosen rows, or all rows if no WHERERow by row, fires delete triggers, can be rolled back
TRUNCATEDDLAll rows, keeping the tableFast, no WHERE clause, usually resets auto-increment counters
DROPDDLThe whole table and its structureData, indexes and permissions on it are gone

In MySQL and Oracle, TRUNCATE commits implicitly and cannot be undone. SQL Server and PostgreSQL can roll it back if it runs inside an explicit transaction.

How Testers Use Each Category, and What to Watch For

  • DDL appears in database migration testing. Check that new columns have the right type, length, default value and constraints, and that old data survives the change.
  • DML is used daily to create test data, set records into edge-case states and verify what the application wrote to the database.
  • DCL supports role-based testing. Log in as a read-only user and confirm that inserts are rejected with a proper error.
  • TCL keeps experiments safe, letting you undo changes after a test.

Mistakes worth avoiding

  • Running UPDATE or DELETE without a WHERE clause. Run the same condition as a SELECT first to see which rows will change.
  • Mixing DDL into a transaction you plan to roll back, in a database where DDL commits automatically.
  • Testing with an all-powerful admin account, which hides permission bugs that real users will hit.
  • Using TRUNCATE on a shared test environment without telling the team.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course