0% found this document useful (0 votes)
9 views2 pages

Exp 10

The document outlines the objectives and theory behind Data Control Language (DCL) and Transaction Control Language (TCL) commands used in database management. It details the syntax and examples for commands such as GRANT, REVOKE, BEGIN TRANSACTION, COMMIT, and ROLLBACK. Additionally, it includes a lab practice assignment for implementing these commands on specific database tables and user roles.

Uploaded by

niravurankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Exp 10

The document outlines the objectives and theory behind Data Control Language (DCL) and Transaction Control Language (TCL) commands used in database management. It details the syntax and examples for commands such as GRANT, REVOKE, BEGIN TRANSACTION, COMMIT, and ROLLBACK. Additionally, it includes a lab practice assignment for implementing these commands on specific database tables and user roles.

Uploaded by

niravurankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment No.

10

Aim:Perform DCL and TCL commands

Theory:

Data Control Language (DCL)

DCL (Data Control Language) includes commands such as GRANT and REVOKE which
mainly deal with the rights, permissions, and other controls of the database system. These
commands are used to control access to data in the database by granting or revoking
permissions.

1.Grant: Assigns new privileges to a user account, allowing access to specific database objects,
actions, or functions.

Syntax:

GRANT privilege_type [(column_list)] ON [object_type] object_name TO user [WITH


GRANT OPTION];

Example:

GRANT SELECT, UPDATE ON employees TO user_name;

2.Revoke: Removes previously granted privileges from a user account, taking away their
access to certain database objects or actions.

Syntax:

REVOKE [GRANT OPTION FOR] privilege_type [(column_list)] ON [object_type]


object_name FROM user [CASCADE];

Example:

REVOKE SELECT, UPDATE ON employees TO user_name;

Transaction Control Language (TCL)

Transactions group a set of tasks into a single execution unit. Each transaction begins with a
specific task and ends when all the tasks in the group are successfully completed. If any of
the tasks fail, the transaction fails. Therefore, a transaction has only two
results: success or failure.

BEGIN TRANSACTION: Starts a new transaction.


Syntax:BEGIN TRANSACTION [transaction_name];

Commit:Saves all changes made during the transaction.

Syntax:COMMIT;

Rollback: Undoes all changes made during the transaction.

Syntax:Rollback;

Savepoint: Creates a savepoint within the current transaction.

Syntax: SAVEPOINT savepoint_name;

Example:

BEGIN TRANSACTION;
UPDATE employees SET department = 'Marketing' WHERE department = 'Sales';
SAVEPOINT before_update;
UPDATE employees SET department = 'IT' WHERE department = 'HR';
ROLLBACK TO SAVEPOINT before_update;
COMMIT;

LAB PRACTICE ASSIGNMNENT:

EMP (empno, empname, salary, phno) Dept (deptno, empno, deptname, location, jobtype)

1.Create the user Jay and implement the following commands on table EMP and Dept.
2. Write a query to grant select, insert, delete privileges on Emp and Dept table.
3. Write a query to grant update privilege on columns of empno and salary on Emp table. 4.
Write a query to revoke all above privileges from Emp and Dept table.
5. Write a query to create role dept_pvr.
6. Write a query to assign system privileges- create table, create view to role dept_pvr;
7. Write a query to assign above system privileges to users Jay and John.
8. Write a query to assign object privileges- select, insert, delete to role dept_pvr.
9. Write a query to assign above object privileges to users’ jay and john.

1. Write TCL command to save all the changes made so far in the EMP
2. Delete any one record in the EMP table created earlier and undo the deletion operation
3. You are in the middle of a transaction and want to set a savepoint named
BeforeSalaryUpdate. Write the SQL command to set this savepoint.

You might also like