Lab Manual
Lab Manual
Alter table
Drop T able
1. CREATE
2. ALTER
3. DROP
4. RENAME
1. CREATE:
(a)CREATE TABLE:
Example:
SQL> CREATE TABLE Student (sno NUMBER (3), sname CHAR (10), class CHAR (5));
2. ALTER:
(a)ALTER TABLE ...ADD...:
Syntax:
ALTER TABLE relation_name ADD (new field_1 data_type(size), new field_2 data_type(size),..);
Example: SQL>ALTER TABLE std ADD (Address CHAR(10));
(b)ALTER TABLE...MODIFY...:
This is used to change the width as well as data type of fields of existing relations.
c) ALTER TABLE...DROP....:
This is used to remove any field of existing relations.
Example:
d)ALTER TABLE…RENAME...:
Example:
3. DROP TABLE:
This is used to delete the structure of a relation. It permanently deletes the records in the table.
Example:
4. RENAME:
It is used to modify the name of the existing database object.
Example: