Data Definition Language (DDL) | Shalini Chauhan

Post

editor-img
Shalini Chauhan
Jan 19, 2023

Data Definition Language (DDL)

Today we will discuss more about DDL commands-

a. CREATE It is used to create a new table in the database.

Syntax:

1. CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]);

Example:

1. CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100), DOB DATE);

b. DROP TABLE

Example

1. DROP TABLE EMPLOYEE;

c. ALTER:

It is used to alter the structure of the database. This change could be either to modify the characteristics of an existing attribute or probably to add a new attribute.

Syntax:

To add a new column in the table

1. ALTER TABLE table_name ADD column_name COLUMN-definition;

To modify existing column in the table:

1. ALTER TABLE MODIFY(COLUMN DEFINITION....);

EXAMPLE

1. ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));

2. ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));

d. TRUNCATE:

It is used to delete all the rows from the table and free the space containing the table.

Syntax:

1. TRUNCATE TABLE table_name;

Example:

1. TRUNCATE TABLE EMPLOYEE;


Tagged users
editor-img
Amit
@quarsh-panaka-ettie
i am a graduate student and currently working with jajal medical services as software engineer.
editor-img
Ravi
@orange-few