Data Definition Language (DDL) is used to specify or create database schema like new database or tables creation along with their properties. It also helps in the alteration and creation of tables, indexes, files, columns, etc within the database. It allows us to create the skeleton of the database.
Some operations that we can perform on the database using DDL:
- CREATE – It is used to create a new database or object.
The syntax for creating table –
CREATE TABLE [table name] ([column definitions]) [table parameters];
The syntax for creating a Database –
- ALTER – It is used to alter the structure of the database ie. modifying the existing database.
ALTER [object-type] [object-name] parameters;
- DROP – It is used to delete objects such as tables, indexes, etc. from the database. After deleting an object, we can’t recover it.
DROP [object-type] [object-name];
- TRUNCATE – It is used to remove all records from a table.
TRUNCATE TABLE [table_name];
- RENAME – It is used to rename the database or object.
RENAME TABLE old_table_name to new_table_name