What is Data Definition Language DDL and how is it used?

The RENAME statement is used along with the ALTER TABLE statement in order to change an object’s name (the object can be a table, column, etc.). On the other hand, the COMMENT statement is used basis sql when we want to add various single-line, in-line and multi-line comments. Here, the semi-colon used at the end of the statement is mandatory, and it is used to process every command before it.

Data Definition Language

It is also used to perform specific tasks, functions, and queries of data. SQL can perform various tasks like creating a table, adding data to tables, dropping the table, modifying the table, set permission for users. We will illustrate three DDL commands (create table, alter table, create index) as we create tables and modify tables using the Library database.


Q.1: What are some of the basic SQL Commands?

TCL is short name of Transaction Control Language which deals with
transaction within a database. DDL is short name of Data Definition Language, which deals with
database schemas and descriptions, of how the data should reside in
the database. I have heard the terms DDL and DML in reference to databases, but I don’t understand what they are. An important thing to keep in mind is that we cannot rename a column with the modified sub-command. One thing needs to be thoroughly kept in mind – DDL deals with the structure of the database and not the data itself. If you want to learn more about SQL, join our SQL Basics course, where we cover all this and more.

For example, with SQL, it would be instructions such as insert, update, delete, … Similar to DROP, the TRUNCATE statement is used to quickly remove all records from a table. However, unlike DROP that completely destroys a table, TRUNCATE preserves its full structure to be reused later. Note that these commands differ greatly between SQL dialects, so the above examples are assuming you’re running Microsoft SQL Server. There are many more commands that deal with database administration, but these differ so much between platforms that it would be overwhelming to deal with them here. These commands have far more features than listed above and their specific syntax tends to vary among SQL dialects.

SQL Basics

DDL is a set of guidelines to which all Structured Query Languages adhere. As in the computer programming languages, we have the OOPS guidelines that all the programming languages adhere to. Similarly, we have Data Definition Language standards that all the database languages adhere to – MySQL, Oracle, SQL Server, etc. It is used to completely delete a table from the database. The table along with the structure is deleted and can’t be found again in the database.

  • Data Query Language (DQL) is used to get data within the schema objects of a database and also to query it and impose order upon it.
  • In general, a constraint can be an arbitrary predicate pertaining to the database.
  • Now we can add data and query the results as and when needed.
  • Such database objects include indexes, tables, schemas, views, and many more.
  • These are used to manage the changes made by DML-statements.