What is DDL?

We often encounter terms like DDL, DML, DQL, DCL, and TCL when using relational database management systems (RDBMSs). But what do they mean?

In this article we’ll look at what DDL stands for and what it does.

What Does DDL Stand For?

In the context of SQL, DDL stands for Data Definition Language or Data Description Language.

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

What Does DDL Do?

Data Definition Language is a subset of SQL that is used to define the structure of a database. It is used to create, alter, and delete database objects such as tables, views, indexes, and stored procedures. DDL statements can also be used to define the relationships between different tables in the database.

For example, a DDL statement might be used to create a table with specific columns, specify the data type for each column, and define the primary key for the table. Another DDL statement might be used to add a new column to an existing table or to alter the data type of an existing column.

DDL is a critical part of database design and maintenance. The accuracy and consistency of the database structure defined by DDL statements is crucial for the proper functioning of the database and the applications that interact with it.

Common DDL Statements

Some of the more commonly used DDL statements include:

  • CREATE TABLE – used to create a new table in the database.
  • ALTER TABLE – used to modify an existing table in the database.
  • DROP TABLE – used to delete a table from the database.

There are many other DDL statements in addition to the ones listed above. The ANSI/ISO SQL standard provides for the creation of schemas, tables, views, domains, character sets, collations, translations, and assertions. Many DBMSs extend the syntax to allow the creation of additional elements, such as indexes, sequences, user profiles, etc.

DDL Example

Here’s an example of a DDL statement:

CREATE TABLE Pets
(
    PetId       int NOT NULL PRIMARY KEY,
    PetTypeId   int NOT NULL,
    OwnerId     int NOT NULL,
    PetName     varchar(60) NOT NULL,
    DOB         date NULL
);

That DDL statement created a table called Pets. It defined five columns within that table, along with their respective data types and constraints.

The exact syntax of DDL statements can differ between each DBMS, but the basic usage is usually very similar for the common ones.

Vendor-Specific DDL Statements

Some DDL statements are vendor-specific. By this I mean each individual database manufacturer might provide their own set of DDL statements for their specific product offerings.

For example, some DBMSs (such as SQL Server) have a CREATE SEQUENCE statement, which is an extension to the ANSI/ISO standard.

DDL vs DML

As seen above, DDL stands for Data Definition Language and it is used to create, alter, and delete database objects.

DML on the other hand, stands for Data Manipulation Language, and it is used to add, delete, and modify the data in the database. The INSERT, UPDATE, and DELETE statements are commonly used DML statements. The SELECT statement is often considered to be a DML statement, but it’s also considered to be a DQL (Data Query Language) statement.

Other DDL Meanings

The term DDL can be applied in different contexts when working with databases. Although it’s most commonly used to refer to Data Definition Language, you may also hear it under different contexts.

Here are various contexts where “DDL” might be used:

  • DDL most commonly stands for to Data Definition Language (as described above), a subset of SQL that is used to define the structure of a database.
  • DDL may also be used as an initialism for Direct Data Loading, which refers to the process of loading data directly into a database or data warehouse, bypassing intermediate staging areas. It’s easy to see how confusing things could get if you’re using DDL to refer to both Data Definition Language and Direct Data Loading.
  • DDL is also the initialism that Cambridge Semantics has given its Direct Data Loading capabilities. Things could get really confusing if we use DDL to refer to Data Definition Language, Direct Data Loading in the general sense, and Direct Data Loading to refer to Cambridge Semantics’ specific direct data loading capabilities.
  • Some people use DDL to refer to a “Dead Dead Line”, which is a deadline that is considered to be final and cannot be extended under any circumstances.

So if you get asked to use DDL to DDL with DDL statements to meet the DDL, you’ll know exactly what to do 😉