Professional Documents
Culture Documents
Assignment No: 01
Assignment Name: Employee Database
Create the database of the following table
employee(empno,empname,job,deptno,salary,dob)
1. List all employee who draws salary not less than 3000/- but more less than 6000/-
2. List employee no. and employee name in employee name order
3. Display all different job types
4. List the details of employee in D2 & D1 in alphabetical order of name
5. Display all employee details whose name have ‘sa’ or ‘am’
6. Show all employee whose date of birth between 1-Jan-1975 & 20-Dec-1979
7. Show the average salary for job excluding manager
8. Add a new field telephone number.
SQL Queries:
SQL> create table emp01
2 (empno varchar2(4),empname varchar2(20),job varchar2(10),deptno varchar2(4),salary
number(6),dob date);
Table created.
1 row created.
SQL> select * from emp01;
7 rows selected.
Q1:
SQL> select empname from emp01
2 where salary between 3000 and 6000;
EMPNAME
--------------------
somnath jana
Page 3
sampa patra
raju mana
ranjan shit
kamini patra
Q2:
SQL> select empno,empname from emp01
2 order by empname;
EMPN EMPNAME
---- --------------------
E004 anikesh bera
E007 kamini patra
E005 raju mana
E006 ranjan shit
E001 saikat jana
E003 sampa patra
E002 somnath jana
7 rows selected.
Q3:
SQL> select job from emp01;
JOB
Page 4
----------
manager
supplier
salesgirl
manager
salesman
salesman
supplier
7 rows selected.
Q4:
SQL> select * from emp01
2 where deptno='D2' or deptno='D1'
3 order by empname;
Q5:
SQL> select * from emp01
2 where empname like '%sa%' or empname like '%am%';
Page 5
Q6:
SQL> select * from emp01
2 where dob between '1-jan-1975' and '20-dec-1980';
AVG(SALARY)
-----------
4700
Q8:
SQL> alter table emp01 add(telno number(11));
Page 6
Table altered.
7 rows selected.
Page 7
Assignment No: 02
Assignment Name: Company Database
Create the database of the following table
Client-master(client_no.,client_name,city,due balance)
Product-master(product no,product description,profit,sellprice)
Salesman-master(salesman no,sales name,city,sales amount)
1. List names of all clients having ‘a’ as the 2nd letter of the name
2. List the clients who stay in a city whose 1st letter is ‘M’
3. List all clients who stay in ‘Bangalore’ or ‘bangalore’
4. List all clients whose balance due is greater than 10,000/-
5. Change the city of client no. ‘C05’ to Bangalore
6. Count the no of product having price less than or equal to 40000/-
7. Determine the maximum or minimum product price
8. List the name and city of salesman who are not in the city Kolkata
SQK Queries:
SQL> create table cmaster
2 (cno varchar2(4),cname varchar2(15),ccity varchar2(10),duebal number(9));
Table created.
7 rows selected.
Table created.
7 rows selected.
Table created.
4 rows selected.
Q1:
SQL> select * from cmaster where cname like '_a%';
Q2:
SQL> select * from cmaster
2 where ccity like 'm%';
Q3:
SQL> select * from cmaster
2 where ccity='Bangalore' or ccity='Mangalore';
Q4:
SQL> select * from cmaster
2 where duebal>10000;
Q5:
SQL> update cmaster set ccity='bangalore'
2 where cno='C05';
1 row updated.
Page 12
7 rows selected.
Q6:
SQL> select pdes from pmaster
2 where price<=40000;
PDES
----------
floppies
mouse
keyboard
cddrive
Q7:
Page 13
MAX(PRICE)
-----------------
300000
MIN(PRICE)
---------------
4000
Q8:
SQL> select sname,scity from smaster
2 where scity<>'kolkata';
SNAME SCITY
--------------- ----------
Mahesh Patel Mumbai
Kiran Dixit Delhi
Nitesh Khan Mumbai
Page 14
Assignment No: 03
Create the database of the following table
patient(p_id, p_name, age, p_address)
doctor(d_id, d_name, d_address)
attend(d_id, p_id)
admitted(p_id, d_o_a)
SQL Queries:
SQL> Create table patient (p_id varchar2(5),p_name varchar2(10),age number(5),p_address
varchar2(10));
Table created.
5 rows selected.
Table created.
3 rows selected.
Table created.
D_ID P_ID
---------- ----------
d_001 p_002
d_001 p_004
d_002 p_001
d_003 p_003
d_003 p_005
5 rows selected.
Q1: List all the patient whose address same with the address of d_id=’d002’
P_ID P_NAME
------- --------------
p_001 suman
p_005 priyanka
Q2: List the doctor id and name who check the patient d_o_a between ‘01-may-05’ to ‘01-
jan-07’
Page 17
Q3: List the name of the patient assecnding order of age with doctor name
P_ID P_NAME
----- -------------
p_005 priyanka
Page 19
Assignment No: 04
Assignment Name: University Database
Create the following table of the Database
enroll(s#, c#, section)
teach (prof, c#, section)
advice(prof, s#)
pre_req(c#, pre_c#)
grade(s#, c#, grade,year)
student(s#, sname)
enroll table :
Table created.
S# C# SECTION
------ ------ --------------
s001 c001 a
s001 c002 b
Page 20
s002 c001 a
s002 c002 b
s003 c001 b
s004 c002 a
6 rows selected.
teach table :
Table created.
PROF C# SECTION
----------- ------- ----------------
korth c001 a
aho c002 b
bekar c001 b
lamp c002 b
4 rows selected.
Page 21
advice table :
Table created.
PROF S#
---------- ------
korth s001
aho s002
2 rows selected.
pre_req table :
Table created.
2 values (‘c001’,’c004’);
C# PRE_C#
------- -------------
c001 c004
c001 c005
c002 c006
c002 c007
4 rows selected.
grade table :
Table created.
S# C# GRADE YEAR
Page 23
9 rows selected.
student table :
Table created.
S# SNAME
Page 24
-------- -------------
s001 suman
s002 sudipta
s003 biplab
s004 chandan
5 rows selected.
Q1: List all the student taking course with ‘suman’ and ‘chandan’
S# C#
------------ ----------
s002 c001
s002 c002
s003 c001
Q2: List all student taking at least one course that their advisor teaches
---------- ---------
s001 suman
s002 sudipta
C#
--------
c001
c002
Q4: List those professor who teach more than one section
PROF
-----------
aho
korth
……………………………………………..
Teacher’s Signature