Вы находитесь на странице: 1из 9

Lab Assignment–1

1. Create table Student (Rno, Name, DOB, Gender, Class, College,City, Marks)
2. Insert 5 records in student table
3. Display the information of all the students
4. Display the detail structure of student table
5. Display Rno, Name and Class information of ‘Patiala’ students.
6. Display information on ascending order of marks
7. Change the marks of Rno 5 to 89.
8. Change the name and city of Rno 9.
9. Delete the information of ‘Amritsar’ city records
10. Delete the records of student where marks<30.
Lab Assignment–2

Based on Emp table: Columns are EmpNo, Ename, Job, Salary, Commission, DeptNO
Insert 5 records by stroring Null value in some records for commission column.
Q1) Get employee no and employee name who work in dept no 10?
Q2) Display the employee names of those clerks whose salary >2000 ?
Q3) Display name and job of Salesperson &Clerks ?
Q4) Display all details of employees whose salary between 2000 and 3000 ?
Q5) Display all details of employees whose dept no is 10, 20, or 30 ?
Q6) Display name of those employees whose commission is NULL ?
Q7) Display dept no & salary in ascending order of dept no and with in each dept no salary
should be in descending order ?
Q8) Display name of employees having two ‘a’ or ‘A’ chars in the name ?
Q9) Display the name of the employees whose second char is ‘b’ or ‘B’ ?
Q10) Display the name of the employees whose first or last char is ‘a’ or ‘A’ ?
Q11) Display maximum, minimum, average salary of deptno 10 employees.
Q12) Display total number of employees working in deptno 20
Q13) Display total salary paid to clerks
Q14) Display system date
Q15) Display the result of (12*12)/13
Q16) Display info of ‘raj’ irrespective to the case in which the data is stored.
Lab Assignment3

Write queries to:


1. Display the system date
2. Display current day
3. Display current month and spell out year
4. Display spell out current date
5. Check whether it is AM or PM right now
6. Display the date of next Friday
7. Round the system date on month
8. Truncate the system date on month
9. Round the system date on year
10. Truncate the system date on year
11. Find the day after three days
Queries Based on EMP table
12. Display day of date of joining column
13. Display those employees who join the company on Monday
14. Display those employees who join the company this month
15. Display those employees who join the company in last 30 days
Create a table train having three four columns
16. Train Number, date of Departure, time of departure, time of arrival
17. Insert five columns in train table
18. Display all the records
19. Display the time values inserted in the columns
20. Display those trains which arrived on PM
21. Display train number who are going to depart in next on hour.
Lab Assignment–4
Q1) Use the following functions _
1. chr (n):
2. cancat(char1,char2):
3. instr(string,char):
4. length(n):
5. lpad(char1 ,n [,char2]):
6. ltrim(string [,char(s)]):
7. rpad(char1 ,n [,char2]):
8. rtrim(string [,char(s)]):
9. replace(char ,search_string , replacement_string):
10. substr(string ,position ,substring length):
11. initcap(char):
12. lower(string):
13. upper(string):
14. translate(char ,from string ,to string):
15. abs(n):
16. ceil(n):
17. cos(n):
18. exp(n):
19. floor(n):
20. mod(m ,n):
21. power(x ,y):
22. round(x [,y]):
23. sign(n):
24. sqrt(n);
25. trunc(x ,n):
26. sysdate:
27. add_months(d ,n):
28. last_day():
29. months_between(date1 ,date2):
30. next_day(date ,char):
31. greatest(expr):
32. least(expr):
Q2) Display current time in hour : min : sec format
Q3) Display salary + commission of emp table
Q4) Store any date value in hiredate column of table ?
Q5) Display name of employee(s) who join the company in 1985 ?
Q6) Display name of the employee(s) who join the company this year ?
Lab Assignment–5

1. Create table emp which has the following attributes (employee table) (@empno, ename, job,
sal, deptno)Where empno is primary key, ename is unique, job in (Prof, AP, and Lect), sal is not
NULL, and deptno default is 10.
Insert appropriate records, check error messages in case of violation and list all the constraint
names for given table.

2. Create table book:


Rno number—PK
DOI-date
DOR-date
DOR>DOI
Insert appropriate records, check error messages in case of violation and list all the constraint
names for given table.

3. Create table st
Rno-Number
Class-Char
Marks-Number
Primary key(rno,class)
Marks>0
Insert appropriate records, check error messages in case of violation and list all the constraint
names for given table.

4. Create table S which has the following attributes (Salesperson table) (sno, sname, city)
Where sno is primary key

5. Create table P which has the following attributes (Part table) (pno, pname, color)
Where pno is primary key

6. Create table SP which has the following attributes (sno, pnoqty)


Where combination of (sno, pno) is primary key, also sno and
pno are foreign keys

7. Create table dept which has the following attributes


(department table) (deptno, dname)Where deptno is primary key, dname in (Acc, comp, elect)

8. Create table emp which has the following attributes (employee


table) (@empno, ename, job, sal, deptno)
Where empno is primary key, ename is unique, job in (Prof, AP, and Lect), sal is not NULL, and
deptno is foreign key
Lab Assignment–6

Q1) Check the structure of tables.


Q2) Check the constraint name for applied constraints?
Q3) Drop the unique constraint on ENAME
Q4) Drop the Foreign Key constraint on DEPTNO
Q5) Add Foreign Key constraint on DEPTNO
Q6) Change Data type of ENAME
Q7) Change width of DNAME
Q8) Add COMM column in EMP table
Q9) Drop CITY column from J table
Q10) Create duplicate copy of EMP table
Q11) Copy structure of DEPT table in another table with different column names
Q12) Change the name and job of the employee whose EMPNO =100
Q13) Delete the record of employee who belong to computer department
Q14) Drop DEPT Table
Q15) Drop duplicate table of EMP table
Lab Assignment 7

S(Sno, Sname, City)


P(Pno, Pname, Color)
SP(Sno, Pno, Qty)
1. Identify primary and foreign keys in each of these tables and create all the tables.
2. Insert five records in each table.
3. Violate the foreign key constraint and identify the oracle errors.
4. Delete record of supplier S1 from S table and write a note on the output of query.
5. Drop table SP and create another table SP1 with delete cascade foreign key option
6. Delete record of supplier S1 from S table and write a note on the output of query.
7. Drop table SP1 and create another table SP2 with delete set null option of foreign key.
8. Delete record of supplier S1 from S table and write a note on the output of query.
9. Alter table SP2 and drop existing foreign key constraint.
10. Add foreign key constraint with alter table option with on delete set default option.
Lab Assignment–8
1. For each part supplied get part number and names of all cities supplying the part.
2. Get Qty supplied for Red parts.
3. Get Sname supplying Red part.
4. Get Sname, Pname who supply qty more than 100.
5. Get all pairs of suppliers numbers such that the two suppliers are located in the same city.
6. Get Sname for suppliers who supply part P2.
7. Get Supplier numbers for suppliers who supply at least one part supplied by supplier S2.
8. Get supplier names for suppliers who do not supply part P2.
9. Get suppliers numbers for suppliers who are located in same city as supplier S1.
10. Get ename and mgrname from emp table
11. Get name of emp who join the company before their managers
12. Get dname and ename also get those deptt which has no emp
13. Get all possible parts which can be supplied by suppliers of patiala
Lab Assignment 9

Solve the following on the given database:


S(Sno, Sname, City, Status)
P(Pno, Pname, Color, Weight)
SP(Sno, Pno, Qty)
1. Create the above tables by identifying appropriate Primary keys and foreign keys.
2. Apply Column level constraints on City such that it may be only “Amritsar”, “Delhi”,
“Batala” and “Qadian”.
3. Apply Column level constraints such that Qty should be between 100 to1000, Weight
is NOT NULL, Sname is NOT NULL and Pname is UNIQUE.
4. Insert five records in each table.
5. Get supplier name where city is “Amritsar”.
6. Get quantity supplied by “Ajay”.
7. Get the supplier name and city that supply part P1.
8. Get color of parts supplied by S1.
9. Get color of parts supplied by Ajay.
10. Get supplier name who supply at least one red part.
11. Get part name where weight>100 and Sno=”S1”.
12. Get supplier name who supply part P1 with quantity>100.
13. Get supplier name who supply pencils with quantity>100.
14. Get supplier number who supplies maximum quantity.
15. Get supplier number who supply quantity greater than average quantity.
16. Get supplier name that supply maximum quantity.
17. Get total number of suppliers.
18. Get total number of parts supplied by supplier S1.
19. Count the parts having red color.
20. Count red parts supplied by Ajay.
21. Get the total quantity supplied by S1.
22. Get maximum quantity supplied by S1.
23. Get the maximum quantity supplied by Rakesh.
24. Get total quantity supplied for each supplier.
25. Get total number of records supplied for each part.
26. Increase the Quantity of part P1 by 10%.
27. Change the color of Red parts supplied by Ajay to Green.
28. Delete all the red parts supplied by supplier S1.
29. Delete all the entries of part P1.

Вам также может понравиться