Aim:
To implement DML, TCL and DRL commands a. Insert (b)Select (c)Update (d)Delete
(e)Commit (f)Rollback (g) Save point
Procedure:
The CREATE statement is used for creating tables, databases, indexes, etc.
Insert command to insert all values in to the tuples.
SELECT command for retrieving data.
Update Command for set to update any previous data.
Delete command to remove all or selective tuple in the table.
Commits the current transaction, making all changes permanent.
Rolls back the current transaction, undoing any changes made since the
last COMMIT.
Sets a savepoint within the current transaction, allowing you to later
ROLLBACK to that specific point.
Program Code:
Data Manipulation Language: (DML Command)
1. Creating the Table:
SQL> CREATE TABLE Employer (Id NUMBER(10) PRIMARY KEY, Name
VARCHAR2(20), Dept VARCHAR2(20), Sem VARCHAR2(20), Address VARCHAR2(20),
Rank VARCHAR2(20));
Table created.
2. Insert the Values
SQL> INSERT INTO Employer VALUES(101,
'Deepak','CSE','II','Bangalore','First');
1 row created.
SQL> INSERT INTO Employer VALUES(102, 'Dinesh','CSE','I','AP','First');
1 row created.
SQL> INSERT INTO Employer VALUES(103, 'RAM','CSE','II','Bangalore','First');
1 row created.
SQL> INSERT INTO Employer VALUES(104, 'Harish','CSE','II','Bangalore','First');
1 row created.
SQL> INSERT INTO Employer VALUES(105, 'Dinesh','CSE','II','Bangalore','First');
1 row created.
SQL> INSERT INTO Employer VALUES(106, 'Tharun','CSE','III','Bangalore','First');
1 row created.
SQL> INSERT INTO Employer VALUES(107, 'Srinithi','CSE','I','AP','Second');
1 row created.
SQL> INSERT INTO Employer VALUES(108, 'Gandhi','CSE','I','AP','Second');
1 row created.
SQL> INSERT INTO Employer VALUES(109, 'Hari','CSE','II','AP','Third');
1 row created.
3. Viewing the table by using SELECT:
SELECT * from Employer; // All data will displayed in table
SELECT * FROM Employer WHERE Dept = 'CSE';
// All data will display where the dept=CSE
SELECT Name FROM Employer WHERE Address = 'Bangalore';
//Name column only display where address= bangalore
4. Update
UPDATE Employer SET Rank= 'Second' WHERE Id = 101;
5. Delete
DELETE FROM Employer WHERE Id = 101;
1 row deleted.
TCL Commands(Transaction Control Language)
6. Commit
COMMIT;
7. RollBack
ROLLBACK TO Myemployer;
8. Save Point
SAVEPOINT Myemployer;
Output:
Result:
Thus the above Program executed Successfully.