Classwork 69103 2
Classwork 69103 2
DATABASE CONCEPTS
AND
SESSION 07
Page 1 of 5
DDL Commands:
Show tables:To list tables in a database
Example:Show tables;
Syntax:
desc <tablename>;
or
describe <tablename>;
2. MODIFY
3. CHANGE
4. DROP
Syntax:
Note: If you want to add more than one column the add clause has to be
repeated according to the number of columns to be added.
Page 2 of 5
Modifying Column Definitions:
To either change the data type or size of an existing column, we make use of the
modify clause Alter table command.
Syntax:
Note: If you want to modify more than one column the modify clause has to be
repeated according to the number of columns to be modified.
To change the existing column names: The change clause of alter table
command is used to change the name of an existing column.
Syntax:
<data type>[<size>];
Note: If you want to change more than one column the change clause has to be
repeated according to the number of columns to be changed.
Deleting columns: To remove the columns from an existing table, we make use
of the drop clause of the Alter table command.
Syntax:
Note: The Drop clause has to be repeated as many as the number of columns
has to be removed from the table.
Page 3 of 5
Drop Table Command:
This is a DDL command which is used to remove the table structure from a
database.
Syntax:
Example:
Create the table Hotel with the following specifications and write commands for
the following:
No Int 5
Name char 25
Type varchar 15
Page 4 of 5
4. To change the data type of Type field to char
Page 5 of 5