0% found this document useful (0 votes)
40 views

What Is DDL in Mysql?: - S.Manoj

DDL stands for data definition language and is used to define and manage databases and their objects like tables, indexes, views, etc. The main DDL commands are CREATE, ALTER, DROP, TRUNCATE, COMMENT, and RENAME. CREATE is used to create databases, tables, indexes, etc. ALTER modifies existing database objects. DROP deletes objects. TRUNCATE removes all records from a table. COMMENT adds comments. RENAME renames objects.

Uploaded by

Manoj Srinivasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

What Is DDL in Mysql?: - S.Manoj

DDL stands for data definition language and is used to define and manage databases and their objects like tables, indexes, views, etc. The main DDL commands are CREATE, ALTER, DROP, TRUNCATE, COMMENT, and RENAME. CREATE is used to create databases, tables, indexes, etc. ALTER modifies existing database objects. DROP deletes objects. TRUNCATE removes all records from a table. COMMENT adds comments. RENAME renames objects.

Uploaded by

Manoj Srinivasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

What is DDL in MySQL?

-S.MANOJ
What is DDL in MySQL?
What is DDL in MySQL?
DDL stands for data definition language. It is a set of SQL statements that work on
the database as a whole, rather than an individual table or row. Create, alter, and
drop are elements of this language. You would use these elements, when you want
to add a table, change the makeup of a table, or delete a table. These operations are
significant, changing the nature of the database in question.
DIFFERENT TYPES OF DDL COMMANDS
• CREATE- to create a database and its objects like (table, index, views, store
procedure, function, and triggers)
• ALTER - alters the structure of the existing database
• DROP - delete objects from the database
• TRUNCATE - remove all records from a table, including all spaces allocated
for the records are removed
• COMMENT - add comments to the data dictionary
• RENAME - rename an object
• CHANGE - Change Keywords allows you to change Name of
Column,Column Data Type,Column Constraints.
• MODIFY - allows you to Modify Column Data Type,Modify Column
Constraints.
SYNTAX
• CREATE
• Syntax:[code lanuage=”sql”] CREATE TABLE <table_name> (
<column_name1> <datatype1> <constraint1>
<column_name2> <datatype2> <constraint2>
<constraint-list>
);
• ALTER
• SQL command can be used to add, modify, or drop a column from the
existing table or to rename a table.
• Syntax:[code lanuage=”sql”] Alter table <table name> add <column
name><data type>;
SYNTAX
• DROP
• Syntax:[code lanuage=”sql”] Drop <table name>;
• Note: Before table drop must remove the dependent constraints
• TRUNCATE
• Syntax:[code lanuage=”sql”] TRUNCATE table <table name>;
• RENAME
• Syntax:[code lanuage=”sql”]
• ALTER TABLE table_name RENAME TO new_table_name;
SYNTAX
• COMMENT
• ALTER TABLE tablename CHANGE ‘column’’column’ COMMENT ‘ …‘;
• CHANGE
• ALTER TABLE tablename CHANGE colname colname datatype
constraint;
• MODIFY
• ALTER TABLE tablename MODIFY colname datatype constraint;
CONSTRAINTS:
• UNIQUE
• NOTNULL
• PRIMARY KEY
• AUTO_INCREMENT
• TIMESTAMP
• ORDER BY
• COMMENT
• DEFAULT
• NULL
THANK YOU

You might also like