What is TCL?

When using relational database management systems (RDBMSs) we often hear terms like DDL, DML, DQL, DCL, and TCL. But what exactly are they?

In this article we’ll look at what TCL stands for in the context of SQL, and what it does.

What Does TCL Stand For?

In the context of SQL, TCL stands for Transaction Control Language.

TCL is a subset of SQL. It’s just one of the various initialisms we can find in SQL. Others include DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), and DQL (Data Query Language).

What Does TCL Do?

Transaction Control Language is a subset of SQL that’s used to manage transactions in a relational database.

TCL includes commands such as COMMIT, ROLLBACK, and SAVEPOINT, although the actual commands required to perform a given task depends largely on the RDBSs being used. For example some RDMBSs use BEGIN TRANSACTION while others use START TRANSACTION to do the same thing.

TCL commands are important for maintaining the consistency, integrity, and reliability of the database in the event of errors or failures during transactions.

TCL Example

Here’s an example of a TCL statement:

BEGIN TRANSACTION MyTransaction

  BEGIN TRY

    DELETE OrderItems WHERE OrderId = 5006;
    DELETE Orders WHERE OrderId = 5006;

    COMMIT TRANSACTION MyTransaction

  END TRY

  BEGIN CATCH

      ROLLBACK TRANSACTION MyTransaction

  END CATCH

That code performed two DELETE functions. The actual delete process required just two lines of code (i.e. the ones starting with DELETE).

The reason there’s more code is because I decided to put them into a transaction (which consists of TCL statements). The reason I did that is just in case one of the delete operations fails. I wouldn’t want one item to be deleted if the other is not deleted. I want both to be deleted or none at all.

That’s the purpose of transactions. They allow us to maintain data integrity by enabling us to manage sequences of SQL statements that must be executed as a single unit of work, so that the database never contains the results of partial operations.

When a transaction makes multiple changes to the database, either all the changes succeed when the transaction is committed, or all the changes are undone when the transaction is rolled back.

See my SQL Transactions Tutorial for a detailed explanation of transactions and more examples of TCL statements.

Other TCL Definitions

The above definition for TCL is just one of many possible definitions. TCL is a simple initialism, and it could mean many different things, depending on the context it is being used. Even in the relatively specific field of software, TCL has many potential definitions. Here are some common ones:

  • Tcl (pronounced “tickle” or as an initialism) can be an initialism for Tool Command Language, a scripting language commonly used for creating and controlling various software applications.
  • TCL can also refer to Terminal Control Language, used to program Verifone devices
  • TCL can refer to Tiny Core Linux, a minimal Linux operating system
  • TCL can refer to Tymshare Conversational Language, a former experimental interactive language
  • TCL can also be used in the context of Think Class Library, a class library for Macintosh featured in THINK C