What is Data Definition Language in MySql

To create an object in our database we need to use DDL(Data Definition Language) statements. DDL (Data Definition Language) are statements used to create and manage data objects in the database. We have 4 types of DDL statements in SQL:

  • 1- Create (creates a new object )
Example
CREATE TABLE table_name
 ( attribute_name_1 data_type_1, attribute_name_n data_type_n);
  • 2-Alter (alters an existing object)
Example
ALTER object_type object_name
    ADD CONSTRAINT constraint_name PRIMARY KEY (attribute list);
  • 3-Drop (drops an existing object)
Example
DROP object_type object_name;
  • 4-Truncate (deletes the content of a table)
Example
truncate table table_name ;
We will go in more depth in the future lessons.