Data Definition Language is the full form of DDL. The computer language DDL can be used to create and modify the configuration of database objects within a database. These database objects comprise different components, such as views, tables, indexes, and schemas. Because it chooses the fields and records in the database table, this is sometimes referred to as a "data description language." Let's explore more about DDL.
Data structures such as tables, indices, and users can be updated using the SQL syntax known as data description language (DDL), also called data definition language. And is employed to specify how a database schema should be described. DDL commands and statements are employed to define data structures, particularly database schemas, in a manner akin to a computer programming language. Examples of DDL commands include create, alter, and drop. When a user accesses a database to view it, they typically do not use these commands. The basic framework of a database structure is formed by these commands, which are used by the database creator.
There are numerous programming languages on the market, some of which are made specifically for modifying databases as well as others for creating them. But in SQL, the DDL language, which covers both operations, is used.
It is a command to create a table in a database, as the command's name suggests. The syntax is as follows:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
….
)
For example,
CREATE TABLE employees (
Employee_serial_no INTEGER PRIMARY KEY,
first_name VARCHAR(25) not null,
last_name VARCHAR(25) not null,
address VARCHAR(150) not null,
city VARCHAR(50) not null
);
DROP Command
The drop command can be used to delete a specific row of data or an entire table.
Syntax:
DROP objecttype objectname.
For Example,
Drop-Table Employee;
Or
Drop-Table Student_List;
All the data in a table except the table itself can be deleted using the "truncate" command. However, there is a distinction between the DROP table and the TRUNCATE command: with the former, the entire table or structure can be deleted, whereas with the latter, the structure is left intact and only the data within the table is deleted.
Syntax:
TRUNCATE TABLE table_name;
For Example,
TRUNCATE TABLE Student_Data;
Or
TRUNCATE TABLE Employee;
The Alter command is used to change a specific table's data. Additionally, it is possible to modify the properties of an object inside a table using the RDBMS (relational database management system). That kind of object is dependent on RDBMS.
Syntax:
ALTER TABLE table_name
ADD column_name datatype;
For example,
ALTER TABLE Student_Data
ADD Roll_No Integer;
Or
ALTER TABLE Employee
DELETE Address;
Another crucial command for commenting on a data structure is this one. It has three types, single-line commands, multi-line commands, and inline commands, just like any other programming language.
Syntax:
Single Line
— comment_1
— comment_2
SELECT * FROM Students;
Multiple Line
/* Comment_1
Comment_2 */
SELECT * FROM Students;
Inline
SELECT * FROM /* Customers;
For example,
Single Line
–Comment:
SELECT * FROM Students;
Multiline
/* SELECT * FROM Students;
SELECT * FROM Student_Data;
SELECT * FROM Employee; */
SELECT * FROM Business;
Inline
SELECT * FROM Students;
SELECT * FROM /* Student_Data;
SELECT * FROM Employee;
SELECT * FROM */ Business;
This command is used to rename a specific table or its contents. ALTER TABLE is another tool that can be used for this.
Syntax:
For renaming a table,
ALTER TABLE table_name
RENAME TO new_table_name;
For example,
Renaming a column
ALTER TABLE Student_Data
RENAME COLUMN roll_number TO serial_number;
As a whole, data description language, also known as Data Definition Language, is a subset of SQL (Structured Query Language). A specific set of phrases or commands is employed when building or managing a database. DDL commands include CREATE, ALTER, DROP, RENAME, COMMENT, and TRUNCATE, to name a few. It is utilised by a database creator and functions in the fundamental framework of a database.
The following categories of SQL commands can be made based on their functionality: DDL (Data Definition Language) DML (Data Manipulation Language) TCL (Transaction Control Language)
The object you want to create should appear in the list of objects. Select New | SQL File by right-clicking a directory of the DDL data source in the Files tool window (View | Tool Windows | Files). In the newly created SQL file, enter a CREATE statement.
Data definition language statements (DDL statements) are statements in SQL files that can be used as data sources. As a result, you can use the editor to refer to any tables, columns, or other objects defined in such files.
A subset of SQL is called Data Definition Language (DDL). It is a language used to describe data and its connections in a database. For database objects, you can create DDL in a script to - Save a copy of the database's layout. Create a test system with a database that behaves like the production system but has no data.
The structure of your tables and other database objects is created and modified using DDL statements. A DDL statement is effective right away after execution.