You are on page 1of 5

SET-1

Create a table called EEMP with the following structure:

Name Type
EMPNO NUMBER(6)
ENAME VARCHAR2(20)
JOB VARCHAR2(10)
DEPTNO NUMBER(3)
SAL NUMBER(8,2)
Allow NULL values for all columns except ename and job.

1. Add a constraint to check the empno value while entering empno>100.


2. Add PRIMARY KEY and NOT NULL constraint to empno.
3. Insert the at least 5 records in the EEMP table.
4. Update the EEMP table to set the salary of employee Raju to 15000 who is working as ‘Developer’.
5. List all the records whose name starts with ‘A’.
6. Display the employee name and deptno whose salary ranges from 15000 to 30000.
7. Display the total salary spent for deptno 201.
8. Display all employee names and salary whose salary is greater than minimum salary of the company and job
title starts with ‘D’.
9. Display a query to find all the employees who work in the same job as Arjun.
10. The organization wants to display only the details of the employees those who are ‘Web Developer’. (With the
help of a view).
11. Write a procedure to calculate average salary, maximum salary and number of employees from EEMP.
12. Create another table called DDEPT to demonstrate FOREIGN KEY and perform equi-join operation.

Name Type
DEPT_ID NUMBER(6)
DEPT_NAME VARCHAR2(20)
DEPT_BRANCH VARCHAR2(10)
EMP_ID NUMBER(6)

13. Write PL/SQL block to find greatest among three numbers.


SET-2

Create a table called AMOVIE with the following structure:

Name Type
ACTOR_ID NUMBER(6)
ANAME VARCHAR2(20)
AGENDER VARCHAR2(10)
MOVIE_NAME VARCHAR2(3)
SAL NUMBER(10,2)
Allow NULL values for all columns except aname and movie_name.

1. Add a constraint to check the actor_id value while entering actor_id>311.


2. Add PRIMARY KEY and NOT NULL constraint to actor_id.
3. Insert the at least 5 records in the AMOVIE table.
4. Update the AMOVIE table to set the salary of actor Rajnikanth to 1,50,000
5. Write a query to display all the information of the movie whose title starts with ‘S’.
6. Display all the information of an actor whose id is any of the 1021, 1389, and 1456.
7. Display the actor name and salary whose salary ranges from 70,000 to 2,30,000.
8. Display the min salary of an actor for movie ‘Hero’.
9. Display a query to find all the actors who work in the same movie as ‘Shah Rukh Khan’.
10. The organization wants to create 2 sets of actor_id starting from 1005 (With the help of a sequence).
11. Create a function to display salary of an actor.
12. Create another table called MMOVIES to demonstrate FOREIGN KEY and perform self-join operation.

Name Type
MOVIE_ID NUMBER(6)
MOVIE_TITLE VARCHAR(20)
MOVIE_YEAR VARCHAR(10)
MOVIE_LANGUAGE VARCHAR(10)
AID NUMBER(6)

13. Write a PL/SQL block to swap two numbers using temp variable.
SET-3

Create a table called EWORK with the following structure:

Name Type
WORKER_ID NUMBER(6)
WORKER_NAME VARCHAR2(20)
WORKER_DEPT VARCHAR2(10)
SAL NUMBER(8,2)
Allow NULL values for all columns except worker_name and worker_dept.

1. Add a constraint to check the worker_id value while entering worker_id>712.


2. Add PRIMARY KEY and NOT NULL constraint to worker_id.
3. Insert the at least 5 records in the EWORK table.
4. Update the EWORK table to set the salary of worker Nikhil to 50,000
5. Write a query to display all the information of the worker whose name starts with ‘N’.
6. Display all the information of an worker whose id is any of the 721, 789, and 756.
7. Display the worker name and salary whose salary ranges from 10,000 to 45,000.
8. Display the max salary of a worker for dept ‘software’.
9. Display a query to find all the workers who work in the same dept as ‘Neha’.
10. Demonstrate savepoint for the above database.
11. Create another table called WDEPT to demonstrate FOREIGN KEY and perform full outer join.

Name Type
DEPT_ID NUMBER(6)
DEPT_NAME VARCHAR2(20)
DEPT_BRANCH VARCHAR2(10)
WID NUMBER(6)

12. Write a PL/SQL block to print reverse of a number.


13. Write a PL/SQL function ODDEVEN to return value TRUE if the number passed to it is EVEN else will return
FALSE.
SET-4

Create a table called BANK_ACC with the following structure:

Name Type
ACCNO NUMBER(6)
CNAME VARCHAR(20)
TYPE VARCHAR2(10)
BNAME VARCHAR2(3)
AMOUNT NUMBER(8,2)
Allow NULL values for all columns except accno, cname, and bname.

1. Add a constraint to check the accno value while entering accno>10105.


2. Add PRIMARY KEY and NOT NULL constraint to accno.
3. Insert the at least 5 records in the EMPL table.
4. Update the BANK_ACC table to set the amount of Raju to 1000 belonging to Syndicate Bank of India.
5. List all the records whose name starts with ‘A’.
6. Display the customer name and bank name whose balance ranges from 0 to 500.
7. Display the total amount for accno 20102.
8. Display all customer names and balance whose balance is greater than minimum balance of Sachin.
9. Display a query to find all the customers who has account as the same as Ashish.
10. The organization wants to display only the details of the customers those who are belonging to ‘ICICI Bank’.
(With the help of a view)
11. Create another table called ORDER to demonstrate FOREIGN KEY and perform right outer join.

Name Type
ORDER_ID NUMBER(6)
AMOUNT NUMBER(10,2)
ITEM_NO NUMBER(6)
ACCNO NUMBER(6)

12. Write a PL/SQL program to find the sum of digits.


13. Create a Simple Trigger that does not allow Insert Update and Delete Operations on the table.
SET-5

Create a table called STUDENT with the following structure:

Name Type
STU_USN NUMBER(6)
STU_NAME VARCHAR2(20)
STU_BRANCH VARCHAR2(10)
MARKS NUMBER(8)
Allow NULL values for all columns except stu_name and stu_branch.

1. Add a constraint to check the stu_usn value while entering stu_usn>712.


2. Add PRIMARY KEY and NOT NULL constraint to stu_usn.
3. Insert the at least 5 records in the STUDENT table.
4. Update the STUDENT table to set the marks of student Nikhil to 590.
5. Write a query to display all the information of the student whose name starts with ‘N’.
6. Display all the information of a student whose usn is any of the 1MJ21CS123, 1MJ21CS146, and 1MJ21CS056.
7. Display the student name and marks whose marks ranges from 500 to 950.
8. Display the max marks of a student for branch ‘CSE’.
9. Display a query to find all the student who work in the same branch as ‘Neha’.
10. The organization wants to display only the details of the student those belonging to ‘ECE’. (With the help of a
view).
11. Create another table called BOOK to demonstrate FOREIGN KEY and perform self-join.

Name Type
BOOK_ID NUMBER(6)
BOOK_NAME VARCHAR2(20)
AUTHOR VARCHAR2(10)
STU_USN NUMBER(6)

12. Write PL/SQL block to find largest of two numbers.


13. Write a procedure to accept a string and print the reverse string.

You might also like