EXPT8 DCL LMD
EXPT8 DCL LMD
EXPT8 DCL LMD
Date of Performance:
Date of Submission:
AIM:
THEORY:
● Using DCL command, it allows or restricts the user from accessing data in database schema.
DCL commands
1. GRANT COMMAND
● GRANT command gives user's access privileges to the database.
Syntax:
GRANT <privilege list>
ON <relation name or view name>
TO <user/role list>;
In the above example, user 'ABC' has been given permission to view and modify the records in
the 'employee' table.
2. REVOKE COMMAND
● This command withdraws access privileges given with the GRANT command.
TCL Commands
● In SQL, TCL stands for Transaction control language.
● A single unit of work in a database is formed after the consecutive execution of commands is
known as a transaction.
● There are certain commands present in SQL known as TCL commands that help the user
manage the transactions that take place in a database.
● COMMIT. ROLLBACK and SAVEPOINT are the most commonly used TCL commands
in SQL.
1. COMMIT
COMMIT command in SQL is used to save all the transaction-related changes permanently to
the disk. Whenever DDL commands such as INSERT, UPDATE and DELETE are used, the
changes made by these commands are permanent only after closing the current session. So
before closing the session, one can easily roll back the changes made by the DDL commands.
Hence, if the changes to be saved permanently to the disk without closing the session, use the
commit command.
Syntax:
COMMIT;
We can divide the database operations into parts. For example, we can consider all the insert
related queries that we will execute consecutively as one part of the transaction and the delete
command as the other part of the transaction. Using the SAVEPOINT command in SQL, we can
save these different parts of the same transaction using different names. For example, save all
the insert related queries with the savepoint named INS. To save all the insert related queries in
one savepoint, we have to execute the SAVEPOINT query followed by the savepoint name after
finishing the insert command execution.
Syntax:
SAVEPOINT savepoint_name;
3. ROLLBACK
While carrying a transaction, we must create savepoints to save different parts of the transaction.
According to the user's changing requirements, he/she can roll back the transaction to different
savepoints. Consider a scenario: We have initiated a transaction followed by the table creation
and record insertion into the table. After inserting records, we have created a savepoint INS.
Then we executed a delete query, but later developer thought that mistakenly he had removed the
useful record. Therefore in such situations, an option of rolling back transaction is available. In
this case, developer has to roll back his transaction using the ROLLBACK command to the
savepoint INS, which we have created before executing the DELETE query.
Syntax:
ROLLBACK TO savepoint_name;
CONCLUSION:
DBA can control the transaction in DBMS using DCL and TCL statement. DCL has two parts
first is the grant and the second is revoke. Likewise, TCL performs in parts such as commit,
rollback, set a save point and transactions.
R1 R2 R3 R4 Total Signature
(3 Marks) (5 Marks) (4 Marks) (3 Marks) (15 Marks)