Sunteți pe pagina 1din 4

SQL PAPER NOV – 2004

Q.1 A. What are the main function of SQL in DBMS ?


(4)
Ans in page 5 of The Complete Ref. by James R. Groff.

B. What is Deferred constraints checking ? Give it’s types.


(4)
Ans in page 316 of The Complete Ref. by James R. Groff.

C. Write the SQL for the Following (2*6)


(12)
i) Display the orders, which were issued in first Quarter of Current year.
select orderNo from Sales_Header where to_char(orderDate,’mm’)<4 and
to_char(orderDate,’yy’)=to_char(sysdate,’yy’)

ii) Display the order number, order date , customer name and order
amount for orders having value of 500 Rs.
select orderNo,orderDate,customer_name,amt from Sales_Header
h,Sales_Detail d where h.orderNo=d.orderNo and amt>=500

iii) Display the order detail where RIN001 soap is sold for Min of 50 Rs.
select h.* from sales_header h,sales_detail d where h.orderNo=d.orderNo
and ProductID=’RIN001’ and Rate>=50

iv) Display the order collected by Executive no. ‘S120’


select orderNo from Sales_Header h,Sales_Detail d where
h.orderNo=d.orderNo and h.salesmanID=’S120’

v) Display the unpaid orders in ascending order of Order No


select orderNo,orderDate from Sales_Header where
paymentstatus=’unpaid’ order by orderNo

vi) Assign the privileges to see the data from both tables to ‘Raj’
Grant select on Sales_Header,Sales_Details to Raj

Table Structure

Sales_Header (OrderNo , OrderDate , CustomerID , Salesmanid ,


PaymentStatus , TransactionType)
Sales_Detail(OrderNo , ProductID , Qty , Rate , Amt)

Q.2. A. Explain the roles plays by SQL


(8)
Ans in page 6 of The Complete Ref. by James R. Groff.
B. Explain the various data types available in SQL2.
(6)
Ans in page 79 of The Complete Ref. by James R. Groff.

C. What is NULL value ? How is it treated in Query Processing?


(6)
Ans in page 91 of The Complete Ref. by James R. Groff.

Q.3.A. Explain the 12 Codd’s Rule.


(8)
Ans in page 65 of The Complete Ref. by James R. Groff.

B. Explain multi-Tier architecture of DBMS. (6)


Ans in page 40 of The Complete Ref. by James R. Groff.

C. i) Display the various types of product sold to Customers.


(6)
select distinct productID from sales_Detail

ii) Display all Credit transaction , with their payment status done in
December 2003
select * from Sales_Header where TransactionType=‘credit’ and
PaymentStatus=’paid’ and to_char(orderDate,’mon-yyyy’)=’Dec-2003’

iii) Display the details of total Cash transaction done by each sales
Executives.
select * from Sales_Header group by salesmanID having
TransactionType=’Cash’

Table Structure

Sales_Header ( OrderNO , OrderDate , CustomerID , SalesmanID,


PaymentStatus , TransactionType)
Sales_Detail ( OrderNo, ProductID , Qty , Rate ,Amt)

Q.4. A. Explain the various types of Search Condition that can be specified in
SQL. (8)
Ans in page 110-128 of The Complete Ref. by James R. Groff.
B. i) Give name of companies located in those cities where ‘TATA’ is
located. (6)
select companyName from company where city in ( select city from
company where companyName=’TATA’)

ii) Give the name of the employees living in the same city where their
company is located .
select ename from Emp e,company c where e.city=c.city

Table Structure
Emp (Empid , ename, city, CompID , salary , Joindate )
Company (CompID , CompName , City)

C. What is Outer Join and why is it used ? Give & explain its subtypes.
Ans in page 178 of The Complete Ref. by James R. Groff.

Q.5. A. What are Integrity Constraints ? Explain any four Integrity Constraints.
(8)
Primary key, foreign key, not null, unique, check
Ans in page 291 of The Complete Ref. by James R. Groff.

B. i) Update salary of employee ‘Raj’ by giving him the salary of ‘Radha’


(6)
working in same company.
update Emp set salary=(select salary from Emp where
Ename=’Radha’)where Ename=’Raj’ and compid=(Select compid from
emp where ename=’Radha’

ii) Display how many male and female members have joined in January
2004.
Select count(ename) from emp group by gender having
to_char(joindate,’mon-yyyy’)=’jan-2004’

iii) Display the total number of companies located in each city.


select count(compid) from company group by city

Table Structure
Emp ( Empid , Ename , CompID , Salary , Joindate , Gender )
Company ( CompID , CompName , City)

C. What are the various methods of Data Insert in SQL.


Ans in page 270-279 of The Complete Ref. by James R. Groff.

Q.6. A. What is View ? Give its Types . Also give its advantages & disadvantages.
(8)
Ans in page 410-421 of The Complete Ref. by James R. Groff.

B. i) Display the details of books whose price is more than the average
price of (6)
all books.
select * from book where price>(select avg(price) from book)

ii) Display the details of books written by ‘Groff’ and supplied by ‘TMGH’
select *from book where Author=’Groff’ and Publisher=’TMGH’

iii) Create a view to show Title , Author , Publisher and Distributer’s Name
& name this view as ShowDetails.
create view ShowDetails(Title, author, publisher, distributor) as
select title, author, publisher, distributor from book

Table Structure
Book (BookID , Title , Author , Publisher , Year , Price , DistID)
Distributors (DistID , Name , City)

C. What is Trigger ? Give its advantages & disadvantage.


(6)
Ans in page 320 of The Complete Ref. by James R. Groff.

Q.7. A. What is database locking ? Why is it used ? Explain the various types of
locks
in SQL2.
(8)
Ans in page 345-348 of The Complete Ref. by James R. Groff.

B. What is privilege ? Explain various types of privileges ? Also explain


ownership privilege .
(6)
Ans in page 440 of The Complete Ref. by James R. Groff.

C. What is versioning ? Give its advantages & disadvantages.


(6)
Ans in page 357-360 of The Complete Ref. by James R. Groff.

------------------------

S-ar putea să vă placă și