DDL Commands
DDL Commands
1. Create
2. Alter
3. Drop
4. Truncate
5. Rename
1.Create
Table name is Student
Column name Data type Size
Reg_no varchar2 10
Name Char 30
DOB Date
Address varchar2 50
Example:
By The use of ALTER TABLE Command we can modify our exiting table.
Syntax:
ALTER TABLE <table_name>
ADD (<NewColumnName> <Data_Type>(<size>),......n)
Example:
ALTER TABLE Student ADD (Age number(2), Marks number(3));
The Student table is already exist and then we added two more
columns Age and Marks respectively, by the use of above command.
Example:
DROP TABLE Student;
It will destroy the table and all data which will be recorded in it.
Syntax:
TRUNCATE TABLE <Table_name>
Example:
TRUNCATE TABLE Student;
Syntax:
RENAME <OldTableName> TO <NewTableName>
Example:
RENAME <Student> TO <Stu>
The old name table was Student now new name is the Stu.
DML Commands:
1. SELECT
2. INSERT
3.UPDATE
4.DELETE
2. INSERT
Note : Character expression placed within the insert into statement must be enclosed in single quotes (').
The UPDATE command is used to change or modify data values in a table and UPDATE
command can Update all the rows from the table or a set of rows from the table.
4. DELETE Operation:
The DELETE command can remove all the rows from the table or a set of rows from the table.
eg: DELETE FROM student; It will DELETE all the rows from student table.
eg: DELETE FROM student WHERE reg_no='A101'; If condition will be satisfied then it will delete
a row from the table Register number A101 will be deleted from the table
If you want to delete table column then use ALTER TABLE command.
eg : ALTER TABLE student DROP COLUMN dob; The DOB column will be
deleted from the student table.