Open In App

Difference between DDL and TCL

Last Updated : 18 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – SQL Commands

 1 Data Definition Language (DDL) is a set of SQL (Structured Query Language) commands used to create, modify, and delete database objects such as tables, indexes, views, and constraints. DDL statements are used to define the schema or structure of a database, including its data types, relationships between tables, and rules for data integrity and security.

Some common DDL commands include:

CREATE TABLE: Creates a new table in the database with specified columns and data types.
ALTER TABLE: Modifies an existing table in the database by adding, modifying, or dropping columns or constraints.
DROP TABLE: Deletes an existing table and all of its data from the database.
CREATE INDEX: Creates an index on one or more columns in a table to improve query performance.
DROP INDEX: Deletes an index from a table.

2. Transaction Control Language (TCL) is a set of SQL (Structured Query Language) commands used to manage transactions within a database. Transactions are a sequence of operations that are treated as a single unit of work, and TCL statements provide the ability to control how transactions are committed or rolled back.

Some common TCL commands include:

COMMIT: This command commits the current transaction, which means that all changes made during the transaction are saved to the database.
ROLLBACK: This command rolls back the current transaction, which means that all changes made during the transaction are undone.
SAVEPOINT: This command creates a savepoint within the current transaction, which allows for partial rollbacks.
ROLLBACK TO SAVEPOINT: This command rolls back the current transaction to a specific savepoint.

Difference between DDL and TCL :

S.No. DDL TCL
1. It stands for Data Definition Language. It stands for Transaction Control Language.
2. It is used to define data structures or overall database schema. It contains those commands, which are used to manage transactions within the database.
3. By using DDL commands, database transactions cannot be handled. TCL commands are meant to handle database transactions.
4. Files can be easily maintained by DDL commands. It manages the different tasks with the important feature, Atomicity.
5. While writing any query, usually DDL statements are written before TCL statements. Usually, TCL statements are written before DDL statements.
6. DDL does not require any log files to maintain the database. It uses log files to keep track of records of all transactions in a database.
7. Some DDL commands which are frequently used : CREATE, ALTER, DROP. Some TCL commands which are frequently used : COMMIT, ROLLBACK.

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads