Structured Query Language DDL - Data Definition Language: 14CS440 / Database Management Systems
Structured Query Language DDL - Data Definition Language: 14CS440 / Database Management Systems
1. CREATE command:
The CREATE statement is used to create an object with the description
like the domain (column), domain_type (data type) and integrity
constraints .
Objects: Table, Index, View, Synonym, Sequence.
Domain type: char, varchar, date, number, integer, lob, etc.
Rajeswari A.M. Page 1 of 4
14CS440 / Database Management Systems 2018
Example:
1. STUDENT( regno, name, branch )
2. MARK ( regno, test_no, sub1, sub2, sub3, result )
CONSTRAINT_NAME C SEARCH_CONDITION
--------------------------------------------------------------------------------
SYS_C001362 C "NAME" IS NOT NULL
P2 P
CONSTRAINT_NAME C SEARCH_CONDITION
--------------------------------------------------------------------------------
SYS_C001368 C "NAME" IS NOT NULL
F2 R
U1 U
2. DROP command:
The SQL DROP statement is used to remove an object from the
database.
If you drop a table, all the rows in the table are deleted and the table
structure is removed from the database.
Once a table is dropped we cannot get it back.
Example:
o DROP TABLE student;
o DROP TABLE mark;
3. ALTER command:
The ALTER TABLE statement is used to add, delete, or modify
columns in an existing table.
The ALTER TABLE statement is also used to add and drop various
constraints on an existing table.
ALTER – ADD option
ALTER TABLE table_name ADD (column_1 column-definition,
column_2 column-definition, ... column_n column_definition);
ALTER – MODIFY option
ALTER TABLE table_name MODIFY (column_1 column_type,
column_2 column_type, ... column_n column_type);
ALTER – DROP option
ALTER TABLE table_name DROP COLUMN column_name;
(not able to drop multiple columns at a time)
Example:
ALTER table student DROP primary key cascade;
CREATE TABLE student1
(regno char(6),name varchar(20),branch char(4));
ALTER TABLE student1 ADD constraint p1 primary key (regno);
**************