Assignment 2
Q.1. Consider following schema:
Depositor (cust_name, acc_no)
Borrower (cust_name, loan_no)
Solve following queries:
(i) Find customer name having saving account as well as loan account.
(ii) Fine customer names having loan account but not the savings account.
Ans : (i) Find customer name having saving account as well as loan account.
Select d.cust_name
From depositor d, borrower b
Where d.cust_name = b.cust_name;
(ii) Fine customer names having loan account but not the savings
account. Select b.cust_name from borrower minus
select d.cust_name from depositor
where d.cust_name = b.cust_name;
Q.2. Describe Commit, Rollback and save point with example.
Ans : 1.Commit :
Commit command is used to make the last transaction permanent in the database.
Commit used to end the transaction and it removes Save Point.
Syntax : commit ;
Example : (After the final transaction.)
Commit;
2.Rollback :
Rollback undo’s the work done in the database.
Syntax : Rollback ; (this is used to roll back to last Save point)
Rollback to Save point < name>; (this is to roll back to particular save point)
Example : Rollback to Save Point V1 ;
3.Save point :
Save point define the breakpoints for the transaction. We can use them to divide big
program/transaction into smaller one.
Syntax : Savepoint <name>;
Example : Savepoint S1;
Q.3. Consider following schema: employee
{empid,empname,designation,salary,deptno}
dept { deptno,deptname,location}
Write SQL queries for following :
Ans : i) Find maximum salary for deptno=10;
select max(salary) from employee where
deptno = 10; ii) Increase salary of all employee
by 5%
Update employee set salary = salary + salary*0.05 ; iii)
Get the names of all ‘Manager’ select empname from
employee where designation like ‘Manager’. iv) Display
deptnames located at ‘Pune’ and ‘Nagpur.
Select deptname from dept where location in
(‘Pune’,’Nagpur’); Q.4. Describe GRANT and Revoke with its
syntax and example.
Ans : Grant :
This command is used to give permission to user to do operation on the other
user object.
Syntax : Grant <object privileges> on <object name> to <username>
[with grant option];
Example: Grant update on student to
yash; Revoke :
This command is used to remove permission from user given to him.
Syntax : Revoke <object privileges> on <object name> from <username>;
Example: Revoke update on student from yash;