0% found this document useful (0 votes)
12 views

No. Questions Answer

1. The document discusses various SQL queries to manage book stock and transaction data stored in Oracle database tables. 2. It includes queries to create tables, insert records, display data, update records, create views and sequences. 3. The last question demonstrates using SQL*Plus commands like SET, TTITLE, BREAK to generate a formatted book issue report from the transaction table.

Uploaded by

minunayak
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

No. Questions Answer

1. The document discusses various SQL queries to manage book stock and transaction data stored in Oracle database tables. 2. It includes queries to create tables, insert records, display data, update records, create views and sequences. 3. The last question demonstrates using SQL*Plus commands like SET, TTITLE, BREAK to generate a formatted book issue report from the transaction table.

Uploaded by

minunayak
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

No.

Questions Answer
1 Create a user of your 1. open oracle with user name system and password imis
own 2. then execute the following commands
a. create user myname identified by mypassword
b. grant connect, dba to myname
3. then logout and open oracle with your user id and
password

2 Create a tables as stock Create table stock(stock_code varchar2(10), book_name


with fields stock_code, varchar2(30), publication varchar2(20), qty number(3), price
Book_Name, number(6))
Publication, Qty, Price
3 Create another table as Create table transaction(on_date date, roll_no
transaction with fields varchar2(7),Transaction_Type varchar2(10),stock_code
on_date, roll_no, varchar2(10))
Transaction_Type,
stock_code)
4 Insert 5 records to the Insert into stock
stock table values(‘&stock_code’,’&book_name’,’&publication’,&qty,&price)
5 Save the records commit
6 Insert some records to Insert into transaction
transaction table values(‘&on_date’,’&roll_no’,’&transaction_type’,’&stock_code’)
Note: Enter transaction
type as Issue or Return
7 Display list of stocks Select * from stock
8 Display book_name, Select book_name, publication, qty from stock
publication and price of
the stocks
9 Display book_name, Select book_name, publication, qty from stock where
publication and qty of publication=’BPB’
BPB publication
10 Display qty of books Select publication,sum(qty) from stock group by publication
available publication
wise
11 Display book_name and Display book_name, publication from stock order by
publication in book_name desc
descending order of
book_name
12 Delete the record of Delete from stock where stock_code=’S005’
stock_code S005
13 Change the size of Alter stock modify(book_name varchar2(50)
book_name to 50
14 Display the system date Select sysdate from dual
15 Display book_name, qty, Select book_name, qty, price, qty * price “Total” from stock
price and total of the
books (here total is qty *
price)
16 Display book_name and Select upper(book_name), upper(publication) from stock
publication in capital
letter
17 Display name of books Select book_name from stock where stock_code in( select
issued to roll_no 10 stock_code from transaction where roll_no=’10’ and
transaction_type=’Issue’)
18 Display list of books Select * from transaction where on_date=’19-Aug-2010’
issued on 19-Aug-2010
19 Display list of books of Select book_name from stock where publication
bpb and techmedia in(‘BPB’,’Publication’)
publication
20 Display name of book Select book_name from stock where book_name like
starting with ‘Management%’
Management
21 Create a view to store Create view stockview as select stock_code, book_name,
stock_code, publication from stock where publication=’BPB’
book_name, publication
of bpb publication
21 Create a sequence to 1. create sequence seq start with 100 increment by 1
generate automatic 2. insert into stock values(‘S’|| seq.nextval, ’&book_name’,
stock_no ’&publication’,&qty,&price)
3. select * from stock
22 Display list of books Select * from stock where stock_code in (select stock_code
issued to roll_no 5 from transaction where roll_no=’5’)
23 Display list of books not Select * from stock where stock_code not in(select stock_code
issued to any one from transaction)
24 Display roll_no of the Select roll_no from transaction where transaction_type=’Issue’
students to whom the and stock_code in(select stock_code from stock where
books of Techmedia publication=’Techmedia’)
publication issued
25 Display list of Select stock_code from stock minus select stock_code from
stock_code not used in transaction
issue or return
26 Create a table student Create table student(roll_no varchar(7) Primary Key, Name
with constraint roll_no as varchar(40) not null, dob date not null, gender varchar(6)
PK, name as not null, default ‘Male’, course varchar(8) check( course
dob as not null, gender in(‘PGDM’,’PGDM(FC)’,’PGDM(RM)’))
as default Male and
course as PGDM,
PGDM(FC) or Note: After creation enter some records to the student table
PGDM(RM)
27 Display date of issue or Select on_date, roll_no, book_name,publication from stock,
return of book, roll_no, transaction where stock.stock_code = transaction.stock_code
name of the book and
publication
28 Display stock_code, Select stock_code, book_name, to_char(price,’$99,999.99’)
book_name and price from stock
(with currency symbol,
comma separator and
decimal point)
29 Display book_name and Select book_name , lpad(to_char(price),10,’*’) from stock
price of book with price
as 10 character
30 Use the sql * plus a. Set Heading On
commands b. Ttitle center ‘Book Issue Report' Right '20 Aug
2010'
c. Btitle Right 'Signature'
d. Break On on_date
e. Compute Count Of stock_code On on_date
f. Set Linesize 80
g. Set Pagesize 20
h. Select on_date,roll_no,stock_code From
transaction Order By on_date

You might also like