Académique Documents
Professionnel Documents
Culture Documents
SQL> create table supp(sup_no number constraint pksup_no primary key,sup_name varch-
ar2(10),item_supplied varchar2(10),item_price number,city varchar2(10)); Table created.
1Q):
SQL> select sup_name,sup_no from supp where sup_name like 'r%';
SUP_NAME SUP_NO
---------- ---------
ramesh 4
2Q)
SQL> select sup_name from supp where item_supplied='processor' and city='delhi';
SUP_NAME
----------
kiran
4Q)
SQL> update supp set item_price=item_price+200 where item_supplied='keyboard';
1 row updated.
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
5Q)
SQL> select sup_no,sup_name,item_price from supp where city='delhi' order by item_price asc;
6Q)
SQL> alter table supp add contact_no number;
Table altered.
7Q)
SQL> delete from supp where item_price=(select min(item_price) from supp);
1 row deleted.
8Q)
SQL> create view vw_supp AS select sup_no,sup_name from supp;
View created.
9Q)
SQL> select * from supp order by item_price desc;
10Q)
SQL> select * from supp where item_supplied NOT IN('processor','keyboard');
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
QUERY:B
Table created.
SQL> insert into empdetails values('e101','suma','29-dec-89','designer',20000,'01-apr-10');
1 row created.
SQL> insert into empdetails values('e102','amit','10-jan-95','programmer',25000,'18-feb-18');
1 row created.
SQL> insert into empdetails values('e103','payal','15-aug-85','tester',35000,'13-jun-11');
1 row created.
SQL> insert into empdetails values('e104','kiran','20-apr-90','programmer',40000,'7-mar-14');
1 row created.
SQL> insert into empdetails values('e105','meenal','29-may-83','dba',50000,'9-dec-11');
1 row created.
SQL> insert into empdetails values('e106','sheila','1-may-70','analyst',60000,'25-sep-18');
1 row created.
SQL> insert into empdetails values('e107','swamy','13-jan-85','programmer',45000,'14-feb-16');
1 row created.
SQL> insert into empdetails values('e108','sushma','22-dec-76','dba',45000,'31-jan-12');
1 row created.
11Q)
SQL> select * from empdetails where designation='programmer';
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
13Q)
SQL> select * from empdetails where ename like '%a';
15Q)
SQL> select upper(ename) from empdetails;
UPPER(ENAME
----------
SUMA
AMIT
PAYAL
KIRAN
MEENAL
SHEILA
SWAMY
SUSHMA
8 rows selected.
17Q)
SQL> select * from empdetails where ename like '%ee%';
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
18Q)
SQL> update empdetails set salary=salary+5000 where designation='dba';
2 rows updated.
8 rows selected.
19Q)
SQL> select * from empdetails where salary>(select avg(salary) from empdetails);
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
20Q)
SQL> select ename,'is working as',designation,'with a salary of rs',salary from empdetails;
8 rows selected.
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
QUERY: C
SQL> create table department_info(dept_id varchar2(5) constraint pkdept_id primary
key,dname varchar2(15) not null);
Table created.
EMPLOYEE TABLE::
SQL> insert into emply values(101,'sudha','d2','clerk',20000,'01-apr-10');
1 row created.
SQL> insert into emply values(102,'david','d1','manager',50000,'18-feb-18');
1 row created.
SQL> insert into emply values(103,'preethi','d3','clerk',35000,'13-jun-11');
1 row created.
SQL> insert into emply values(104,'kiran','d1','salesman',20000,'7-mar-14');
1 row created.
SQL> insert into emply values(105,'meenal','d2','clerk',50000,'9-dec-11');
1 row created.
SQL> insert into emply values(106,'sunitha','d3','manager',60000,'25-sep-18');
1 row created.
SQL> insert into emply values(107,'akhil','d3','clerk',25000,'14-feb-16');
1 row created.
SQL> insert into emply values(108,'sushma','d2','manager',45000,'31-jan-12');
1 row created.
_____________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
21Q)
SQL> select * from emply where salary>(select avg(salary) from emply);
8 rows selected
23Q)
SQL> select * from emply order by salary desc;
8 rows selected..
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
24Q)
SQL> select designation,count(emid) from emply group by designation;
DESIGNATION COUNT(EMID)
--------------- -----------
clerk 4
manager 3
salesman 1
26Q)
SQL> select * from emply where designation='clerk' and dept_id='d2';
27Q)
SQL> select * from emply where to_char (doj,'yyyy')=2011;
28Q)
SQL> select * from emply where to_char (doj,'mon')='feb';
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
QUERY:D
SQL> create table students(sid number constraint pksid primary key,sname varchar2(10),dob
date,state varchar2(15),gender varchar2(2),category varchar2(10),course varchar2(10));
Table created.
31Q)
SQL> select * from students where state not in ('telanagana','andhra pradesh');
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
32Q)
SQL> create view vw_stud as select sid,sname from students where state='telangana';
View created.
SQL> select * from vw_stud;
SID SNAME
--------- ----------
1001 neha
1002 arun
33Q)
SQL> create index indx_state on students(state);
Index created.
34Q)
SQL> select * from students where gender='f' and course='comp' and category='obc';
36Q)
SQL> select sid,sname,course from students order by sname asc;
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
37Q)
SQL> delete from students where course='comp' and to_char(dob,'yyyy')>2002;
2 rows deleted.
38Q)
Table altered.
SQL> alter table students add email varchar2(10);
Table altered.
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
QUERY:E
AUTHOR
----------
agarwal
sc gupta
42Q)
SQL> select publisher,sum(price) "total cost" from library group by publisher;
COUNT(PUBLISHER)
----------------
2
45Q)
SQL> select * from library order by datepurchased asc;
6 rows selected.
46Q)
SQL> create index indx_bookauthor on library(bookname,author);
Index created.
47Q)
SQL> select * from library where price between 500 and 700;
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System
48Q)
SQL> update library set price=price+200 where publisher not in('himalaya','kalyani');
2 rows updated.
6 rows selected.
49Q)
SQL> select * from library where author like '%sharma%';
50Q)
SQL> create view vw_library as select bookid,bookname from library where
publish-er='himalaya';
View created.
BOOKID BOOKNAME
-------- ---------------
b102 buss stat
b106 adv acc
______________________________________________________________________________
Name:- D. Sai Ram Karthik
Course:- B.com (C) 6th Semester
HT.No:- 121116402014
Subject:- Relational DataBase Management System