Ex2 Dbms
Ex2 Dbms
2
AIM: To study and implement DDL commands.
DDL (Data Definition Language):
DDL or Data Definition Language actually consists of the SQL commands that can be
used to define the database schema. It simply deals with descriptions of the database schema
and is used to create and modify the structure of database objects in the database. DDL is a set
of SQL commands used to create, modify, and delete database structures but not data. These
commands are normally not used by a general user, who should be accessing the database via
an application.
CREATE
Syntax,
The column parameters specify the names of the columns of the table. The datatype parameter
specifies the type of data the column can hold (e.g. varchar, integer, date, etc.).
Examples,
DESCRIBE
As the name suggests, DESCRIBE is used to describe something. Since in database we have
tables, that’s why we use DESCRIBE or DESC(both are same) command to describe
the structure of a table.
DROP
Syntax,
Examples,
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
The ALTER TABLE statement is also used to add and drop various constraints on an existing
table.
1. You can add or modify column but you can’t drop it from table
4. You can change the datatype if the column contains null values(column is empty)
5. Decrease the width of column if the column contains only null values or if the table has
no rows
TRUNCATE
The TRUNCATE TABLE command deletes the data inside a table, but not the table
itself.
Examples,
Syntax,
Example,