Exp 10
Exp 10
10
Theory:
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:
Example:
2.Revoke: Removes previously granted privileges from a user account, taking away their
access to certain database objects or actions.
Syntax:
Example:
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.
Syntax:COMMIT;
Syntax:Rollback;
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;
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.