Transaction Control Language (TCL) is a subset of SQL used to manage transactions in a database. A transaction is a logical unit of work that may consist of one or more SQL statements—typically INSERT
, UPDATE
, or DELETE
—that should be executed together.
TCL provides commands to ensure that transactions are properly completed or rolled back in case of errors.
Command | Description |
---|---|
COMMIT |
Saves all changes made in the current transaction permanently to the database. |
ROLLBACK |
Undoes all changes made since the last COMMIT . |
SAVEPOINT |
Creates a named point within a transaction that you can roll back to later. |
ROLLBACK TO SAVEPOINT |
Reverts changes back to a specific savepoint. |
SET TRANSACTION |
Defines characteristics for the current transaction (e.g., isolation level). |
BEGIN;
UPDATE account SET balance = balance - 100 WHERE account_id = 1;
UPDATE account SET balance = balance + 100 WHERE account_id = 2;
COMMIT;
→ Both updates are completed together. If an error occurs, you could use ROLLBACK
to cancel both operations.
TCL commands only work in database systems that support transactions (e.g., PostgreSQL, Oracle, or MySQL with InnoDB).
A Character Large Object (CLOB) is a data type used in database systems to store large amounts of text data. The term stands for "Character Large Object." CLOBs are particularly suitable for storing texts like documents, HTML content, or other extensive strings that exceed the storage capacity of standard text fields.
TEXT
types, which function similarly to CLOBs.TEXT
or specialized data types.
SQL stands for "Structured Query Language," and it is a specialized programming language primarily used for managing and querying databases. SQL is a crucial component in the world of databases and is supported by many relational database management systems like MySQL, PostgreSQL, Microsoft SQL Server, Oracle Database, and SQLite.
SQL allows users to create, edit, query, and delete data in a database. Here are some of the basic tasks that can be performed with SQL:
Data Query: SQL enables you to query data from a database to extract information, typically using SELECT statements.
Data Modification: You can update data in a database to modify, add, or delete existing records using UPDATE, INSERT, and DELETE statements.
Database Management: You can create, modify, and delete databases, as well as manage user permissions and security settings.
Database Structure: SQL allows you to define the structure of a database, including tables, indexes, relationships, and constraints.
SQL is a standardized language, meaning that the fundamental principles and syntax are largely the same in most relational database management systems. However, there are also differences and extensions supported by various database systems. Developers use SQL to access and manipulate structured data, which is crucial in a wide range of applications and systems.