0% found this document useful (0 votes)
77 views9 pages

Practical - 5: CE246-DBMS Roll - No: 19CE005

The document discusses various Data Control Language (DCL) and Transaction Control Language (TCL) commands in SQL. It provides examples of common DCL commands like GRANT and REVOKE which are used to manage privileges on database objects. It also discusses TCL commands like COMMIT, ROLLBACK, and SAVEPOINT which are used to manage transactions within a database. The document includes questions and answers providing examples of using these commands.

Uploaded by

Jaineel Bhavsar
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)
77 views9 pages

Practical - 5: CE246-DBMS Roll - No: 19CE005

The document discusses various Data Control Language (DCL) and Transaction Control Language (TCL) commands in SQL. It provides examples of common DCL commands like GRANT and REVOKE which are used to manage privileges on database objects. It also discusses TCL commands like COMMIT, ROLLBACK, and SAVEPOINT which are used to manage transactions within a database. The document includes questions and answers providing examples of using these commands.

Uploaded by

Jaineel Bhavsar
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/ 9

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.

Examples of DCL commands:


Commands that come under DCL:

 Grant
 Revoke

Grant:
This command is use to give user access privileges to a database.

Syntax:

GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;

Revoke:
It is useful to back permissions from the user.

Syntax:

REVOKE privilege_nameON object_nameFROM {user_name |PUBLIC |role_name}

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.

U & P U Patel Department of Computer Engineering Page 1


CE246-DBMS Roll_No : 19CE005

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.

A grant all privileges on employees to c##ved;

U & P U Patel Department of Computer Engineering Page 2


CE246-DBMS Roll_No : 19CE005

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.

A revoke all privileges on employees from c##ved;

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;

Q-5 Write a query to implement the save point.

A //this is before updating the table

//after updating

U & P U Patel Department of Computer Engineering Page 3


CE246-DBMS Roll_No : 19CE005

//now creating save point


savepoint ved_correct_sal;

//if by mistake updating ved salary I wrote salary=100

//Now to revive correct salary using savepoint

U & P U Patel Department of Computer Engineering Page 4


CE246-DBMS Roll_No : 19CE005

Q-6 Insert into employees values(‘c03’,’nishit’,50000,’c01’);


(In my case I had entered details according to my table mentioned in schema section) i.e.
Here c03 as 209 and c01 as 80
Insert into employees values(209,’nishit’,’N Uzumaki’,’nmail’,’’,’14-JUN-05’,’’,’SA_REP’,50000,’’,’’,80);
A insert into employees values(209,'nishit','N Uzumaki','nmail','','14-JUN-05','SA_REP',50000,'','',80);

Q-7 Select * from employees;

Q-8 Write a query to implement the rollback.

A Rollback;

Q-9 Select * from employees;

U & P U Patel Department of Computer Engineering Page 5


CE246-DBMS Roll_No : 19CE005

Q10 Write a query to implement the commit.

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)

U & P U Patel Department of Computer Engineering Page 6


CE246-DBMS Roll_No : 19CE005

U & P U Patel Department of Computer Engineering Page 7


CE246-DBMS Roll_No : 19CE005

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;

U & P U Patel Department of Computer Engineering Page 8


CE246-DBMS Roll_No : 19CE005

U & P U Patel Department of Computer Engineering Page 9

You might also like