Practical - 5: CE246-DBMS Roll - No: 19CE005
Practical - 5: CE246-DBMS Roll - No: 19CE005
PRACTICAL – 5
Aim To study various Data Control Languages (DCL),Transfer Control Language (TCL)
commands
THEORY:
DCL (Data Control Language) includes commands like GRANT and REVOKE, which are
useful to give "rights & permissions." Other permission controls parameters of the
database system.
Grant
Revoke
Grant:
This command is use to give user access privileges to a database.
Syntax:
Revoke:
It is useful to back permissions from the user.
Syntax:
Transaction control language or TCL commands deal with the transaction within the
database.
Commit:
This command is used to save all the transactions to the database.
Syntax:
Commit;
Rollback:
Rollback command allows you to undo transactions that have not already been saved to
the database.
Syntax:
ROLLBACK;
SAVEPOINT:
This command helps you to sets a savepoint within a transaction.
Syntax:
SAVEPOINT SAVEPOINT_NAME;
----------------------------------------------------------------------------------------------------------------------
Creating user:
Q-1 Develop a query to grant all privileges of employees table to c##ved user.
Q-2 Develop a query to grant some privileges of employees table to c##ved user.
Providing some privileges like select, insert, update, alter to user c##ved.
A grant select,update,alter,insert on employees to c##ved;
Q-3 Develop a query to revoke all privileges of employees table to c##ved user.
Q-4 Develop a query to revoke some privileges of employees table to c##ved user.
Revoking some privileges like select, insert, update, alter from user c##ved.
A revoke update,insert,select,alter on employees from c##ved;
//after updating
A Rollback;
A Commit;
Schema :
Create a table department1 ( dept _no varchar(3), dept_ name varchar(20), dept_location varchar(50) ); Create a
table employee1 ( emp_id varchar(3) , emp_name varchar(20) , emp_salary number(5,2),dep_no varchar(3));
(I am using default oracle HR schema employees and departments table and locations table for getting locations
from location_id in departments table)
PRACTICAL – 10
Aim To perform basic pl/sql blocks
Q Write a PL-SQL block for checking weather a given year is a Leap year or not
A DECLARE
year NUMBER(4);
BEGIN
year:= &year;
IF MOD(year,4)=0
AND
MOD(year,100)!=0
OR
MOD(year,400)=0 then
dbms_output.Put_line(year || ' is a leap year.');
ELSE
dbms_output.Put_line(year || ' is not a leap year.');
END if;
END;