You are on page 1of 8

Sample programs

1. Create the following tables with given attributes having appropriate data type and specify the necessary
Primary and foreign key constraints:
Customer (Custid, Custname, Age, phone)
Loan (Loanid, Amount, Custid, EMI)
a) List the name of the customers who have taken loan for more than Rs.50,000.
b) List the Customer id of those who have no loan.
c) List the total count of loan availed.
d) Create a procedure to print the Amount and Custid when the Loanid is given as input. Handle
Exceptions.

2. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Employee (EmpId, Empname, Sal, Deptno)
Dept (Deptno, Dname, Loc, DeptmanagerId)
a) List the count of Employees and average salary of each department.
b) List the employee name, department name and the salary of all the employees.
c) Display the Employee name and the respective department manager name.
d) Create a function to return the salary of the employee when Empid is given as input parameter.
Handle Exceptions.

3. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
User (Userid, Name, Dept, Bookid, Accdate)
Book (Bookid, Book_name, Author, Publication, Price)
a) List the name of the user who had accessed the costliest book.
b) List the userid and count of books accessed by the user.
c) List the books published by Wiley publisher.
d) Write a PL/SQL program to print the details of the book when Bookid is given as input.
Handle appropriate exceptions.

4. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
User (Userid, Name, Dept, Bookid, Accdate)
Book (Bookid, Book_name, Author, Publication, Price)
a) List the name of the user who had accessed the costliest book.
b) List the userid and count of books accessed by the user.
c) List the books published by Wiley publisher.
d) Write a PL/SQL program to print the details of the book when Bookid is given as input.
Handle appropriate exceptions.

5. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Customer (Custid, Custname, Addr, phno,panno)
Loan (Loanid, Amount, Interest, Custid)
Account (Acctno, Accbal, Custid)
a. Display the Account balance amount of a particular customer “ARUN”
b. Update the interest with 1% when Accbal of the Custid >50% of Loan Amount
c. Create a View with Accbal and Loan Amount of all Customers
d. Create a trigger which checks for minimum balance in the account.
6. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Customer (Custid, Custname, phno, pan, DOB)
HomeLoan (HLoanid, Amount, Custid)
VehicleLoan (VLoanid, Amount, Custid)
a) List the Custid of the customers who have both homeloan and vehicle loan.
b) List the Custid of the customers who donot have any loan.
c) Create a view with customerid, Customer name and total loan amount (HomeLoan and
VehicleLoan)
d) Write a trigger which displays the Homeloan details whenever the values are inserted in the
respective table.

7. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Product (Prodid, Prodesc, Price, Stock)
Sales (Salesid, Prodid, qty)
a) Add a column reorder in Product table having value 50 for all products.
b) Create a Login form to validate a user.
c) Create a Form using Menus to
(i) Add a product.
(ii) Delete a product.

8. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Product (Prodid, Prodesc, Price, Stock)
Sales (Salesid, Prodid, qty)
a) Add a column reorder in Product table having value 50 for all products.
b) Display the Sales Report.
c) Create an application for
i) User Login &
ii) Checking the availability of a product in a stock.

9. Design a Database for Library Management System using ER Diagram.


Create the following table with the given attributes having appropriate data type and specify the
necessary key constraints.
 BOOK(Bookcode,Name,Author,Price,Publish)
Design forms to
a) Login
b) Add & delete book details

10. Create an application for student contacts management application. The application enables a
faculty user to login and search the details of a Student (Name, Address, Contact no, Email id,
parent contact) with his register number. Create necessary tables and Forms.

11. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Marks (Regno,Name , Dept, Subj1,Subj2,Subj3)
a) Add a column Total in student table and update the Total field with the sum of 3 subject
Marks.
b) Find the second maximum total in the table.
c) Display the name of the student with maximum total.
d) Write a PL/SQL program to display the report sheet of the students using cursors.

12.Create an application for Quiz system. Create the necessary table(s) with attributes having
appropriate data type and specify the necessary key constraints.
13. Create the following tables with the mapping given below.
stu_details (reg_no, stu_name, DOB, address, city)
mark details (reg_no, mark1, mark2, mark3, total)
(a) Alter the table mark details to add a column average with data type as long.
(b) Display the months between the DOB and till date.
(c) Using alter command drop the column address from the table stu_details.
(d) Write a PL/SQL program to find the sum & average marks of all the student using
procedures.

14. Create the following tables with the mapping given below.
Employee (Empno, Ename, Job, MgrId, DOB, DoJ, Sal, Comm, Deptno)
Department (Dname, Deptno, Dloc)
(a) Display the EMP no, name, salary and experience of each employee ordered by salary
(highest to lowest)
(b) List the names of the employee working for “Marketing” Department.
(c) List the names of the employees born in the current month.
(d) Write a PL/SQL function to display the details of the employee when Employee no given as
input. Handle Exceptions.

15. (a) Create a table Student (Regno, name , Mark) and insert records. Write a PL/SQL function to
print the grade of the Student. Obtain student mark as input from the main program. Check for
the following condition: if the input mark ranges 91-100 then Grade A, 81-90 then Grade B,
71-80 then Grade C, 60-70 then Grade D and <60 Grade E.
(b) Develop an application for Banking System. Design a Database schema and create necessary
tables and forms.

16. (a)Write a PL/SQL program to print the pay slip of the employee. Create a table Employee (Id,
Name, Basic pay, DOB, Dept).Obtain Employee id as input from the main program. (Basic pay
+DA+HRA-TAX-DED). Assume the Allowances and Deduction %.
(b) Develop an application for Employee payroll processing System to add, delete, update
employee particulars and generate pay slip with the employee table created in (a).

17. (a) Create a table Bank (acc_no, name, balance) and insert records into the table. Write a PL/SQL
Program for the Bank table to notify the user if the account balance is less than 500. Obtain
account no as input. Handle Exceptions.
(b)Develop an application for inventory management System. Design a Database schema and Create
necessary tables and forms.

18. (a) Create the table Book (acc_no, username, bookno, days) and insert few records into the table.
Write a PL/SQL Program to calculate the fine for library book (Rs 5 /day). (Hint: fine =days*5).
Obtain account no as input. Handle Exceptions.
(b). Design a Database schema for Library management System. Develop an application for
managing book details in Library management System.

19. Create the following tables with given attributes having appropriate data type and specify the necessary primary
and foreign key constraints:
Customer (Custid, Custname, Age, phone)
Loan (Loanid, Amount, Custid, EMI)
a) List the name of the customers who have taken loan for more than Rs.50,000.
b) List the Customer id of those who have no loan.
c) List the total count of loan availed.
d) Create a procedure to print the Amount and Custid when the Loanid is given as input. Handle
Exceptions.
20. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Employee (EmpId, Empname, Sal, Deptno)
Dept (Deptno, Dname, Loc, DeptmanagerId)
a) List the count of Employees and average salary of each department.
b) List the employee name, department name and the salary of all the employees.
c) Display the Employee name and the respective department manager name.
d) Create a function to return the salary of the employee when Empid is given as input parameter.
Handle Exceptions.

21. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
User (Userid, Name, Dept, Bookid, Accdate)
Book (Bookid, Book_name, Author, Publication, Price)
a) List the name of the user who had accessed the costliest book.
b) List the userid and count of books accessed by the user.
c) List the books published by Wiley publisher.
d) Write a PL/SQL program to print the details of the book when Bookid is given as input.
Handle appropriate exceptions.

22. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
User (Userid, Name, Dept, Bookid, Accdate)
Book (Bookid, Book_name, Author, Publication, Price)
a) List the name of the user who had accessed the costliest book.
b) List the userid and count of books accessed by the user.
c) List the books published by Wiley publisher.
d) Write a PL/SQL program to print the details of the book when Bookid is given as input.
Handle appropriate exceptions.

23. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Customer (Custid, Custname, Addr, phno, panno)
Loan (Loanid, Amount, Interest, Custid)
Account (Acctno, Accbal, Custid)
a. Display the Account balance amount of a particular customer “ARUN”
b. Update the interest with 1% when Accbal of the Custid >50% of Loan Amount
c. Create a View with Accbal and Loan Amount of all Customers
d. Create a trigger which checks for minimum balance in the account.

24. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Customer (Custid, Custname, phno, pan, DOB)
HomeLoan (HLoanid, Amount, Custid)
VehicleLoan (VLoanid, Amount, Custid)
a) List the Custid of the customers who have both homeloan and vehicle loan.
b) List the Custid of the customers who do not have any loan.
c) Create a view with customerid, Customer name and total loan amount (HomeLoan and
VehicleLoan)
d) Write a trigger which displays the Homeloan details whenever
the values are inserted in the
respective table.
25. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Product (Prodid, Prodesc, Price, Stock)
Sales (Salesid, Prodid, qty)
a) Add a column reorder in Product table having value 50 for all products.
b) Create a Login form to validate a user.
c) Create a Form using Menus to
(i) Add a product.
(ii) Delete a product.

26. I. Create a table ‘Student’ with the following details (table level constraints)
Rollo number (5) Primary key
Name varchar2 (10)
Course code number (2) Foreign key (Reference ‘Course’ table)
Mark1 number (3) Check whether values range from 0 to 100
Mark2 number (3) Check whether values range from 0 to 100
II .Create a table ‘Course’ with the following details (table level constraints)
Ccode number (2) Primary key
Course varchar2 (10)
A. Add the field total to table student
B. Insert 5 records into the table. Don’t input values for total field
C. List the student names and their course names
D. Write a PL/SQL block to find whether the given number is odd or even
E. Write a database trigger before delete for each row on table course, delete corresponding course
students from Student table

27. I. Create a table ‘Employee’ with the following details (Column level constraints)
Empno Number (5) Primary key
Empname Varchar2 (20) Designation Varchar2 (10)
Date_of_join Date
Salary Number (9,2) NOT NULL
Depno Number (2) Foreign key (Reference ‘Department’ table)
II.Create another table called ‘Department’ with the following structure (Column level
constraints)
Depno Number(2) Primary key
Depname Varchar2 (15)
Deplocation Varchar2 (10)
A. Display the number of employees in each department with the department numbers in descending
order
B. List the departments where there are employees functioning
C. List the employees whose depno is not equal to ‘01’
D. Write a PL/SQL block to find the factorial of a number
E. Write a PL/SQL procedure which accepts depno as input and increase the salary of the
corresponding department employees by 5% in the employee table
28. I. Create a table order master with the following fields
Order no varchar2 (5) Ordate date
Vencode varchar2 (5)
Ordstatus char (1) (p-pending,d-delivered)
Del_date Date
II.Create a table order detail with the following fields
Orderno varchar2 (5) Item code varchar2 (5)
Qty_ord number (5) Qty_deld number (5)
A. Display the information on orders being handled by a vendor whose Vencode is ‘V004’ according
to the delivery date order
B. List the orders which have been placed after ’01-Jan-2006’ and before ’01-Jul-2006’
C. List out the pending orders
D. Write a PL/SQL block to find whether the given year is leap year or not
E. Write a PL/SQL block to display a particular order details. Display appropriate message if the
Order is not found.

29. I. Create a table ‘Student’ with the following details (table level constraints)
Rollno number (5) Primary key
Name varchar2 (10)
Course code number (2) Foreign key (Reference ‘Course’ table)
Mark1 number (3) Check whether values range from 0 to 100
Mark2 number (3) Check whether values range from 0 to 100
II.Create a table ‘Course’ with the following details (table level constraints)
Ccode number (2) Primary key
Course varchar2 (10)
A. Add the field total to table student
B. Insert 5 records into the table. Don’t input values for total field.
C. List the student name with the highest mark1
D. Write a PL/SQL function to find the factorial of a given number
E. Write a database trigger to display the total number of records after inserting a record into the
table

30. i.Create a table member with the following fields member code, member name, phoneno.
ii.Create a table book with the following fields bookcode, category code, bookname, cost.
iii.Create a table issue with the following fields membercode, Book code, Issuedate, Returndate.
A. List all the members names who have taken the book on 8-10-2007.
B. List the member codes of the members who have taken books worth more than Rs. 400.00.
C. Write a PL/SQL block to generate the Fibonacci series
D. Write a PL/SQL block using cursor to display the contents of various tables based on the options

31. Create a table vendor master with the following fields


Vencode varchar2 (5) Venname varchar2 (15)
Venadd1 varchar2 (30) Venadd2 varchar2 (30)
Venadd3 varchar2 (30)
A. Change the address of the vendor with Vendor code ‘V002’ in Vendor_master
B. Display the next occurrence of ‘Friday’ to the current date.
C. Find the total number of vendors.
D. List the vendor names start with the letter ‘A’.
E. Write a PL/SQL block to find whether the given number is odd or even
F. Write a PL/SQL block using cursor to display the total number of records and delete a record
32. i. Create a table ‘Student’ with the following details (table level constraints)
Rollno number (5) Primary key
Name varchar2 (10)
Course code number (2) Foreign key (Reference ‘Course’ table)
Mark1 number (3) Check whether values range from 0 to 100
Mark2 number (3) Check whether values range from 0 to 100
ii. Create a table ‘Course’ with the following details (table level constraints)
Ccode number (2) Primary key
Course varchar2 (10)
A. Add the field total to table student
B. List the student names starting with the letter ‘S’.
C. Update the total field by adding Mark1 and Mark2
D. Write a PL/SQL block to find whether the given year is leap year or not
E. Write a PL/SQL block using cursor to display the student names and their corresponding
course names.

33. i.Create a table ‘Employee’ with the following details(Column level constraints)
Empno Number (5) Primary key
Empname Varchar2 (20) Designation Varchar2 (10)
Date_of_join Date
Salary Number (9,2) NOT NULL
Depno Number (2) Foreign key (Reference ‘Department’ table)
ii.Create another table called ‘Department’ with the following structure (Column level constraints)
Depno Number (2) Primary key
Depname Varchar2 (15)
Deplocation Varchar2 (10)
A. Display the number of employees in each department with the department numbers in descending
order
B. Display designation, department no and total number of employees designation wise and
department wise.
C. List the Employee names and their department names.(Use Outer join)
D. Write a PL/SQL block to find whether the given number is odd or even
E. Write a database trigger before insert or update for each row on the table employee not allowing
to enter salary > 25,000

34. Create a table item file with the following fields


Item code varchar2 (5) Itemdesc varchar2 (30)
P_categoryvarchar2 (30) (Spares, Accessories)
Qty_hand number (5) Re_level number (5)
Maxlevel number (5) Itemrate number (9,2)
A. Display the quantity required (maxlevel – Qtyhand) of each item under the category of spares to
reach the maximum level
B. Find the item with maximum rate in each product category
C. Find the items whose quantity in hand is less than the maximum level for the ‘spares’ category
D. Find the total number of items under ‘Accessories’ category.
E. Write a PL/SQL block to find whether the given year is leap year or not
Write a PL/SQL block to display a particular item details. Display appropriate message if the item
is not found.
35. i.Create a table member with the following fields member code, member name, phoneno.
ii.Create a table book with the following fields bookcode, category code, bookname, cost.
iii.Create a table issue with the following fields membercode, Book code, Issuedate, Returndate.
E. List all the members’ names who have taken the book on 8-10-2007.
F. List the member codes of the members who have taken books worth more than Rs. 400.00.
G. Write a PL/SQL block to generate the Fibonacci series
H. Write a PL/SQL block using cursor to display the contents of various tables based on the options

You might also like