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

Dbms Lab Internal 2

This document contains questions related to SQL queries and PL/SQL programs on sample relational schemas for employees, workers, sailors etc. It asks to write queries for retrieving, filtering, aggregating data from the tables and writing PL/SQL programs for operations like finding factorial, checking even-odd numbers, generating exceptions etc. There are around 14 sections with 4-5 questions in each section covering different types of SQL and PL/SQL concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Dbms Lab Internal 2

This document contains questions related to SQL queries and PL/SQL programs on sample relational schemas for employees, workers, sailors etc. It asks to write queries for retrieving, filtering, aggregating data from the tables and writing PL/SQL programs for operations like finding factorial, checking even-odd numbers, generating exceptions etc. There are around 14 sections with 4-5 questions in each section covering different types of SQL and PL/SQL concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

DBMS LAB INTERNAL 2

1. (A).Consider the following Relational Schema


WORKERS(WORKER ID, FIRST NAME,LAST NAME ,SALARY,JOINING
DATE,DEPARTMENT)
BONUS(WORKER_ID, BOUNS DATE,BONUS AMOUNT)
DEPARTMENT(WORKER ID,DEPT NAME,AFFECTED FROM)

 Write an SQL query to fetch “FIRST_NAME” from the Worker table using the alias
name <WORKER_NAME>.

 Write an SQL query to fetch “FIRST_NAME” from the Worker table in upper case.

 Write an SQL query to fetch unique values of DEPARTMENT from the Worker
table.

 Write an SQL query to print the first three characters of  FIRST_NAME from the
Worker table.
(B).Create a view on workers table and perform insertion and update on view.
(C ).Write a PL/SQL Program to find factorial of a positive number.

2. (A). Consider the following Relational Schema


WORKERS(WORKER ID, FIRST NAME,LAST NAME ,SALARY,JOINING
DATE,DEPARTMENT)
BONUS(WORKER_ID, BOUNS DATE,BONUS AMOUNT)
DEPARTMENT(WORKER ID,DEPT NAME,AFFECTED FROM)
 Write an SQL query to find the position of the alphabet (‘a’) in the first name column
‘Amitabh’ from the Worker table.
 Write an SQL query to print the FIRST_NAME from the Worker table after removing
white spaces from the right side.
 Write an SQL query to print the DEPARTMENT from the Worker table after
removing white spaces from the left side.
 Write an SQL query that fetches the unique values of DEPARTMENT from the
Worker table and prints its length.
(B).Create a TRIGGER to ensure that workers table does not contain duplicate or
null values in workers column.
(C ). Write a PL/SQL Program Print the grade of the student using case statement
3. (A). Consider the following Relational Schema
WORKERS(WORKER ID, FIRST NAME,LAST NAME ,SALARY,JOINING
DATE,DEPARTMENT)
BONUS(WORKER_ID, BOUNS DATE,BONUS AMOUNT)
DEPARTMENT(WORKER ID,DEPT NAME,AFFECTED FROM)

 Write an SQL query to print the FIRST_NAME from the Worker table after replacing
‘a’ with ‘A’.

 Write an SQL query to print the FIRST_NAME and LAST_NAME from the Worker
table into a single column COMPLETE_NAME. A space char should separate them.

 Write an SQL query to print all Worker details from the Worker table order by
FIRST_NAME Ascending and DEPARTMENT Descending.

 Write an SQL query to print details for Workers with the first names “Vipul” and
“Satish” from the Worker table.
(B). Create trigger that doesn’t  allow a salary to be updated if the Worker id is null.
(C). Write a PL/SQL program to find largest of 3 numbers

4. (A). Consider the following Relational Schema


WORKERS(WORKER ID, FIRST NAME,LAST NAME ,SALARY,JOINING
DATE,DEPARTMENT)
BONUS(WORKER_ID, BOUNS DATE,BONUS AMOUNT)
DEPARTMENT(WORKER ID,DEPT NAME,AFFECTED FROM)
 Write an SQL query to print details of workers excluding first names, “Vipul” and
“Satish” from the Worker table.
 Write an SQL query to print details of Workers with DEPARTMENT name as
“Admin”.
 Write an SQL query to print details of the Workers whose FIRST_NAME contains
‘a’.
 Write an SQL query to print details of the Workers whose FIRST_NAME ends with
‘a’.
(B ). Create a trigger that inserts or updates values of first name and last name
as uppercase strings even if we give lowercase strings in workers table.
(C ). Write a PL/SQL program to find sum of digits of a positive number

5. (A). Consider the following Relational Schema


WORKERS(WORKER ID, FIRST NAME,LAST NAME ,SALARY,JOINING
DATE,DEPARTMENT)
BONUS(WORKER_ID, BOUNS DATE,BONUS AMOUNT)
DEPARTMENT(WORKER ID,DEPT NAME,AFFECTED FROM)

 Write an SQL query to print details of the Workers whose FIRST_NAME ends with
‘h’ and contains six alphabets.

 Write an SQL query to print details of the Workers whose SALARY lies between
100000 and 500000.

 Write an SQL query to fetch the no. of workers for each department in descending
order.

 Write an SQL query to fetch the no. of workers for each department in descending
order.
 Write an SQL query to print details of the Workers who are also Managers.
(B). Write a PL/SQL block to Generate Fibonacci Series
(C ).Create a view on department table .

6. (A). Consider the following Relational Schema


WORKERS(WORKER ID, FIRST NAME,LAST NAME ,SALARY,JOINING
DATE,DEPARTMENT)
BONUS(WORKER_ID, BOUNS DATE,BONUS AMOUNT)
DEPARTMENT(WORKER ID,DEPT NAME,AFFECTED FROM)

 Write an SQL query to fetch duplicate records having matching data in some fields of
a table.
 Write an SQL query to show only odd rows from a table.
 Write an SQL query to show only even rows from a table.
 Write an SQL query to show the current date and time.
 Write an SQL query to show the top n (say 10) records of a table.
 Write an SQL query to fetch the list of employees with the same salary.
(B). Write a PL/SQL program to find multiplication table
(C ). PL/SQL Program to raise NO_DATA_FOUND_ exception for workers table

7. (A). Consider the following Relational Schema


WORKERS(WORKER ID, FIRST NAME,LAST NAME ,SALARY,JOINING
DATE,DEPARTMENT)
BONUS(WORKER_ID, BOUNS DATE,BONUS AMOUNT)
DEPARTMENT(WORKER ID,DEPT NAME,AFFECTED FROM)

 Write an SQL query to show the second-highest salary from a table.


 Write an SQL query to fetch the first 50% of records from a table.
 Write an SQL query to fetch the departments that have less than five people in them.
 Write an SQL query to show all departments along with the number of people in
there.
(B). Write a PL/SQL program to find multiplication table
(C ). Write a PL/SQL Program to Raise an exception when data type is changed

8. (A). Consider the following Relational Schema


WORKERS(WORKER ID, FIRST NAME,LAST NAME ,SALARY,JOINING
DATE,DEPARTMENT)
BONUS(WORKER_ID, BOUNS DATE,BONUS AMOUNT)
DEPARTMENT(WORKER ID,DEPT NAME,AFFECTED FROM)

 Write an SQL query to fetch departments along with the total salaries paid for each of
them.
 Write an SQL query to fetch the names of workers who earn the highest salary.
 Write an SQL query to fetch three max salaries from a table.
 Write an SQL query to fetch three min salaries from a table
(B). Write a PL/SQL program to print 1 to 10 numbers using While and For loop
(C).Write a PL/SQL Program to raise Divide by zero exception.

9. (A).Consider the following Relational Schema


EMPLOYEE ( EMPNO , ENAME , MGR , HIREDATE, SAL, DEPTNAME)
INCENTIVES(EMPID ,INCENTIVE_DATE ,INCENTIVE_AMOUNT )
 Display all the information of the Employee table
 Display unique Department names from Employee table.
 List the details of the employees in ascending order of their salaries.
 List the employees who joined before 1981.
 List the Empno, Ename, Sal, Daily Sal of all Employees in the ASC order of AnnSal.
(B).Write a PL/SQL Program to check whether the given number is even or odd.
(C ). PL/SQL Program to insert,update and delete Employee table

10. (A).Consider the following Relational Schema


EMPLOYEE ( EMPNO , ENAME , MGR , HIREDATE, SAL, DEPTNAME)
INCENTIVES(EMPID ,INCENTIVE_DATE ,INCENTIVE_AMOUNT )
 List the employees who are working for the department name BANKING or
INSURANCE
 List the employees who are joined in the year 1981
 List the employees who does not belong to department name INSURANCE
 Select employee details from employee table if data exists in incentive table ?
 Get Employee ID’s of those employees who didn’t receive incentives
(B ).Write a PL/SQL Program to print the total number of rows of incentives table.
(C). Write a PL/SQL Program to add two integers.

11. (A).Consider the following Relational Schema


EMPLOYEE ( EMPNO , ENAME , MGR , HIREDATE, SAL, DEPTNAME)
INCENTIVES(EMPID ,INCENTIVE_DATE ,INCENTIVE_AMOUNT )
 Query to rank employees based on their incentives for a month
 SQL Query to print the number of employees per department in the organization
 SQL Query to find the employee details who got second maximum incentive in
Febrauary 2019
 SQL Query to find the employee who got minimum incentive in 2019
 SQL Query to find the employee who did not get any incentive in january 2019
(B).Write a PL/SQL Program to demonstrate Explicit Cursors.
12. (A).Consider the following Relational Schema
EMPLOYEE ( EMPNO , ENAME , MGR , HIREDATE, SAL, DEPTNAME)
INCENTIVES(EMPID ,INCENTIVE_DATE ,INCENTIVE_AMOUNT )
 SQL Query to find the month where Employees got Maximum incentive.
 SQL Query to select the employees getting salary greater than the average salary of
the department that are working in
 SQL Query to compute the group salary of all the employees.
 SQL Query to list the employees and name of employees reporting to each person.
 SQL Query to find the department with highest number of employees.
(B ).Write a PL/SQL Program to print the total number of rows of EMPLOYEE table.

13. (A).Consider the following Relational Schema


SAILORS(SID,SNAME,RATING,AGE)
BOATS(BID,BANME,COLOR)
RESERVES(Sid,BID,DATE)
 Write a Query to Find the names of sailors who have reserved boat number 103.
 Write a Query to Find the sids of sailors who have reserved a red boat.
 Write a Query to Find the colors of boats reserved by Lubber.
 Write a Query to Find the ages of sailors whose name begins and ends with B and has
at least three characters.
(B). Write a PL/SQL program to find multiplication table
(C ). Write a PL/SQL Program to print the total number of rows of Boats table.
14. (A).Consider the following Relational Schema
SAILORS(SID,SNAME,RATING,AGE)
BOATS(BID,BANME,COLOR)
RESERVES(Sid,BID,DATE)
 Write a Query to Find the names of sailors who have reserved a red or a green boat.
 Write a Query to Find the names of sailors who have reserved both a red and a green
boat.
 Write a Query to Find all sids of sailors who have a rating of 10 or have reserved boat
104
 Write a Query to Find the names of sailors who have reserved boat 103 using IN
Operator
(B). Write a PL/SQL Program to find factorial of a number using procedures.
(C ). Create a View on Boats table.

15. (A).Consider the following Relational Schema


SAILORS(SID,SNAME,RATING,AGE)
BOATS(BID,BANME,COLOR)
RESERVES(Sid,BID,DATE)
 Write a Query to Find the names of sailors who have reserved a red boat using IN
operator
 Write a Query to Find the names of sailors who have not reserved a red boat using IN
operator
 Write a Query to Find the names of sailors who have reserved boat number 103 using
EXISTS.
 Write a Query to Find sailors whose rating is better than some sailor called Horatio.
(B). Write a PL/SQL Procedure for Fibonacci series.
(C).Write a PL/SQL Program to demonstrate implicit cursors.

16. (A).Consider the following Relational Schema


SAILORS(SID,SNAME,RATING,AGE)
BOATS(BID,BANME,COLOR)
RESERVES(Sid,BID,DATE)
 Write a Query to Find the sailors with the highest rating
 Write a Query to Find the names of sailors who have reserved both a red and a
green boat using IN .
 Write a Query to Count the number of sailors.
 Write a Query to Find the average age of all sailors.
(B). Write a PL/SQL procedure for swapping of two numbers
(C ).Write a PL/SQL program to print 10 to 1 numbers using for loop.

17. (A).Consider the following Relational Schema


SAILORS(SID,SNAME,RATING,AGE)
BOATS(BID,BANME,COLOR)
RESERVES(Sid,BID,DATE)
 Write a Query to find the average age of sailors with a rating of 10.
 Write a Query to find the age of the oldest sailor.
 Write a Query to find the names of sailors who are older than the oldest sailor
with a rating of 10
 Write a Query to for each red boat, find the number of reservations
(B). Write a PL/SQL function to find number of SAILORS.
(C ).Write a PL/SQL program to add two integers.
18. A).Consider the following Relational Schema
SAILORS(SID,SNAME,RATING,AGE)
BOATS(BID,BANME,COLOR)
RESERVES(Sid,BID,DATE)
 Write a Query to Find the average age of sailors for each rating level that has
at least two sailors.
 Write a Query to Find the average age of sailors who are of voting age (i.e., at
least 18 years old) for each rating level that has at least two sailors.
 Write a Query to Find the average age of sailors who are of voting age (i.e., at
least 18 years old) for each rating level that has at least two such sailors.
 Write a Query to Find those ratings for which the average age of sailors is the
minimum overall ratings.
(B). Create a view on Sailors table and perform insertion and update on view
(C ). Write a PL/SQL Program to find factorial of a number using functions

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy