DBMS Lab Week4
DBMS Lab Week4
DDL Commands:
DDL means Data Definition Language. It is used to create an object, alter the structure of an
object and also drop already created object.
The Data Definition Languages used for table definition can be classified into following:
• Rename
SQL - CREATE TABLE: Table is a primary object of database, used to store data in form of
rows and columns.
Syntax:
CREATE TABLE tablename (column_name data_ type constraints, …)
Example:
MYSQL > CREATE TABLE STUDENTS ((SID INT PRIMARY KEY, SNAME VARCHAR
(10), BRANCH VARCHAR (10), AGE INT );
Table Created.
Desc command
The DESCRIBE command is used to view the structure of a table as follows.
MYSQL>DESC STUDENTS;
EXERCISE:
2. ALTER TABLE :
To ADD a column:
To DROP a column:
3. RENAME A TABLE
SYNTAX:
MYSQL> RENAME table oldtablename TO newtablename;
EXERCISE:
1. PRACTICE THE COMMAND BY RENAMING THE ALREADY CREATED TABLES
4. TRUNCATE A TABLE
SYNTAX:
MYSQL> TRUNCATE TABLE tablename;
EXERCISE:
1. PRACTICE THE COMMAND ON THE ALREADY CREATED TABLES
5. DROP A TABLE
SYNTAX:
MYSQL> DROP TABLE tablename;
EXERCISE:
1. PRACTICE THE COMMAND BY DROPING THE ALREADY CREATED TABLES