1.
DDL --- Data Definition Language :
❖ DDL is used to construct an object in the database and deals with
the Structure of the Object
a) CREATE :
▪ It is used to create an object inside the data base.
▪ object can be table or view
Syntax:
CREATE TABLE Table_Name
(
Column_Name1 datatype constraint_type ,
Column_Name2 datatype constraint_type ,
……
Column_NameN datatype constraint_type );
b) RENAME :
▪ It is used to change the name of the table.
Syntax:
Rename existing_table_name to new_table_name;
c)ALTER :
▪ It is used to modify the structure of the table.
1.TO ADD A COLUMN :
Syntax:
ALTER TABLE Table_Name
ADD Column_Name Datatype Constraint_type ;
2.TO DROP A COLUMN :
1|Page
Syntax:
ALTER TABLE Table_Name
DROP COLUMN Column_Name ;
3.TO RENAME A COLUMN :
Syntax:
ALTER TABLE Table_Name
RENAME COLUMN Column_Name TO new_Column_Name ;
4.TO MODIFY THE DATATYPE :
Syntax:
ALTER TABLE Table_Name
MODIFY COLUMN_NAME New_Datatype;
5.TO MODIFY NOT NULL CONSTRAINTS :
Syntax:
ALTER TABLE Table_Name
MODIFY COLUMN_NAME Existing_datatype [NULL]/NOT
NULL;
d)TRUNCATE :
▪ IT IS USED TO REMOVE ALL THE RECORDS FROM
THE TABLE PREMANENTLY
Syntax:
TRUNCATE TABLE Table_Name ;
e)DROP :
▪ IT IS USED TO REMOVE THE TABLE FROM THE
DATABASE.
2|Page
Cust
Cid Cname Phone_no Address DROP
1 A 1234567890 Bglr BIN
2 B 1234567899 Mysore
3 C 1234567880 Mglr
▪ Table will not be deleted permanently instead it’ll store inside
the bin folder.
▪ Inside the data base it’ll display the memory address where
the deleted table is pushed
Syntax:
DROP TABLE Table_Name ;
TO RECOVER THE TABLE :
Syntax:
FLASHBACK TABLE Table_Name
TO BEFORE DROP ;
TO DELETE THE TABLE FROM BIN FOLDER :
Syntax:
PURGE TABLE Table_Name ;
▪ Table will be permanently deleted from the binfolder can’t be
undo .
NOTE :
▪ DDL statements are auto - commit.
2.DATA MANIPULATION LANGUAGE ( DML ) :
▪ It is used to Manipulate the Object by performing insertion ,
updating and deletion .
▪ DML commands are not auto commit which should be save
Extensively using TCL commands .
3|Page
TYPES OF DML STATEMENTS:
1.INSERT : It is used to insert / create records in the table .
Syntax:-1
INSERT INTO Table_Name VALUES( v1 , v2 , v3 …… ) ;
Syntax:-2
2.UPDATE : It is used to modify an existing value .
Syntax:
UPDATE Table_Name
SET Col_Name = Value , Col_Name = Value ,….
[WHERE stmt ] ;
3.DELETE : It is used to remove a particular record from the table .
Syntax:
DELETE FROM Table_Name
[ WHERE stmt ];
3.TCL (TRANSACTION CONTROL LANGUAGE) :
▪ It is used to control the transactions done on the database .
▪ The DML Operations performed on the Database are known as
Transactions such as Insertion , Updating and Deletion .
▪ We have 3 Statements
1. COMMIT :
▪ This statement is used to SAVE the transactions into the DB .
Syntax:
COMMIT;
2.ROLLBACK:
4|Page
▪ This statement is used to Obtain only the saved data from the DB .
▪ It will bring you to the point where you have committed for the last
time .
Syntax:
ROLLBACK ;
3.SAVEPOINT:
▪ This statement is used to mark the positions or restoration points .
(nothing related to DB ) .
Syntax:
SAVEPOINT Savepoint_Name ;
Syntax:
ROLLBACK TO Savepoint_Name ;
4. DCL ( DATA CONTROL LANGUAGE) :
▪ This statement is used to control the flow of data between the users.
We have 2 statements :
1.GRANT :
▪ This statement is used to give the permission to another user.
Syntax:
GRANT SQL_STATEMENT
ON TABLE_NAME
TO USER_NAME ;
2.REVOKE :
▪ This statement is used to remove the permission from other user.
Syntax:
5|Page
REVOKE SQL_STATEMENT
ON TABLE_NAME
FROM USER_NAME ;
Requirement to create the table inside the data base:
6|Page