0% found this document useful (0 votes)
20 views4 pages

DBMS Experimentdbms-3

The document discusses data definition language (DDL) commands in relational database management systems. It describes commands to create, alter, modify, drop and rename database tables and columns. It provides the syntax and examples of commands like create table, add column, drop column, modify column, rename table, rename column, truncate table, and drop table.

Uploaded by

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

DBMS Experimentdbms-3

The document discusses data definition language (DDL) commands in relational database management systems. It describes commands to create, alter, modify, drop and rename database tables and columns. It provides the syntax and examples of commands like create table, add column, drop column, modify column, rename table, rename column, truncate table, and drop table.

Uploaded by

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

EXPERIMENT-3

Aim: Data Definition Language (DDL) commands in RDBMS.

Tools/ Apparatus:
HARDWARE REQUIREMENTS:

INTEL PENTIUM DUAL CORE

80GB HDD

512MB DDR

SOFTWARE REQUIREMENTS:

ORACLE 10g

Procedure:

To create a DDL to perform creation of table, alter, modify and drop column.

DDL COMMANDS

1. The Create Table Command: - It defines each column of the table uniquely. Each column has
minimum of three attributes, a name, data type and size.

Syntax:

Create table <table name>


(<col1> <datatype>(<size>),
<col2> <datatype><size>)
);
Ex:

CREATE TABLE EMP (


ID NUMBER,
EMP_NAME VARCHAR (20),
EMP_MN NUMBER (10),
EMP_CITY VARCHAR (20),
PRIMARY KEY (ID)
);
2. Modifying the structure of tables.

a) Add new columns


Syntax:
Alter table <tablename> add
(<new col><datatype(size),<new col>datatype(size));

Ex: ALTER TABLE EMP add

(EMP_SALARY NUMBER(4,2) NULL);


3. Dropping a column from a table.
Syntax:
Alter table <tablename> drop column <col>;
Ex: ALTER TABLE EMP DROP COLUMN EMP_SALARY;

4. Modifying existing columns.


Syntax:
Alter table <tablename> modify(<col><newdatatype>(<newsize>));
Ex: ALTER TABLE EMP MODIFY (EMP_SALARY NUMBER (8,2));

5. Renaming the tables

Syntax:

Rename Table Name-

Rename <oldtable> to <new table>;

Ex. ALTER TABLE EMP RENAME TO EMP_NEW

Rename Column Name-


alter table <tablename> rename column <old_column> to <new_column>;

Ex: ALTER TABLE EMP RENAME COLUMN EMP_MN TO EMP_MOB;

6. truncating the tables.

Syntax:

Truncate table <tablename>;

Ex: truncate table EMP;

7. Destroying tables.

Syntax:

Drop table <tablename>;

Ex: DROP TABLE EMP;

8. DESC or DESCRIBE
Example: desc emp;
Describe emp;

You might also like