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

DBMS Pratical Questions

Uploaded by

madhanlap0402
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

DBMS Pratical Questions

Uploaded by

madhanlap0402
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.Create a Table as workers and the details are { S.

No, Name, Designation, Branch }


Perform the following commands:
i. Alter the table by adding a column Salary
ii. Alter the table by modifying the column Name
iii. Describe the table employee
iv. Copy the table employee as emp
v. Truncate the table
vi. Delete the Second row from the table
vii. Drop the table.
viii. Write a PL/SQL program to print the given number is odd or even.

2.Create the following tables


student_details{register_no, student_name, DOB, address, city}
mark_details{register_no, mark1, mark2, mark3, total }
i. Display only those rows whose total ranges between 250 and 300.
ii. Drop the table mark_details and Delete the row whose register_no=161.
iii. Display all details whose names begins with 'a'.
iv. Write a PL/SQL program to print the details of the student when regno is given as input.
3.Consider the following relational schema for a Loan database application:
Customer{Customer_id, Customer_name, Age, phone_no}
Loan{ Loan_id, Amount, Customer_id)}
i. Include the constraint on Loan_id that it starts with letter ‘L’.
ii. Display the list of the customer_ids and total Loan amount taken.
iii. Display the Customer_id and Customer_name who have taken less than two loans
Write a PL/SQL program to print the details of the customer when customerid is given as input
4.Consider the following database for a Banking Enterprise.
Branch{branch_name, branch_city, assets) Account(accno, branch_name, balance}
Depositor {customer_name, accno) Customer(customer_name, customer_street,
customer_city}
Loan {loan_number, branch_name, amount}
Borrower { customer_name, loan_number)}
i. Create the above tables by properly specifying the primary keys and foreign keys and
enter at least five tuples for each relation.
ii. Find all the customers who have at least two accounts at the main branch.
iii. Find all the customers who have an account at all the branches located in a specific
city.
iv. Write a PL/SQL program to delete all account tuples at every branch located in a
specific city.
5.Consider the following database consisting of the following tables:
Hostel (hno, hname, type [boys/girls])
Menu (hno, day, breakfast, lunch, dinner)
Warden (wname, qual, hno)
Student (sid, sname, gender, year, hno)
i. Display the total number of girls and boys hostel in the college.
ii. Display the menu in the hostel ‘x’ on Tuesday.
iii. Display the number of wardens for each hostel.II.
iv. Write a PL/SQL program to print given number is Prime or not.
v.
8.Consider the employee relational database, Where the primary keys are underlined.
Employee ( employee_name, street, city)
Works ( employee_name, company_name, salary)
Company ( comapny_name, city)
Manages ( employee_name, manager_name)
a) Find all employees in the database who earn more than each employee of Small Bank
Corporation.
b) Assume that the companies may be located in several cities. Find all companies located
in every city in which Small Bank Corporation is located.
c) Give all managers of first Bank Corporation a 10 percent raise unless the salary
becomes greater than $100,000; in such cases, give only a 3 percent raise.
d) Write a PL/SQL program to print given number Armstrong or not.
9.Consider the following relational schema:
Employee( empno, name, office, age ) Books ( isbn, title, authors, publisher )
Loan( empno, isbn, date )
Write the following queries in SQL:
a) Print the names of employees who have borrowed any books published by McGraw-
Hill.
b) Print the names of employees who have borrowed all books published by McGraw-
Hill.
c) For each publishers, print the names of employees who have borrowed more than five
books of that publisher.
d) Write a PL/SQL program to print the greatest of three numbers.
10.i. Create a table as book (sl.no, book_name, author_name,price, edition,publisher_name ).
Perform the following operations:
a) Insert minimum ten tuples in book table
b) Commit the table book
c) Create a save point for the table book as B
d) Rollback the table book after inserting 4 & 5 row
e) Define Grant & Revoke
ii.Create a view contains slno,book_name,price.
iv. Write a PL/SQL program to print the greatest of two numbers.
11.Create a table salesman{ salesman_id, name, city, commission } and
customer{customer_id, name, city, grade, slaesman_id}. Write the following query:
a) Create a view for those salesmen belongs to the city New York
b) Create a view for all salesmen with columns salesman_id, name, and city
c) Find the salesmen of the city New York who achieved the commission more than 13%.
d) Create a view to getting a count of how many customers we have at each level of a
grade
e) Write a PL/SQL program to print the greatest of three numbers.
12.Consider the following relational schema for a Loan database application:
Customer{Customer_id, Customer_name, Age, phone_no}
Loan{ Loan_id, Amount, Customer_id)}
i. Include the constraint on Loan_id that it starts with letter ‘L’.
ii. Display the list of the customer_ids and total Loan amount taken.
iii. Display the Customer_id and Customer_name who have taken less than two loans
iv.Write a PL/SQL program to print the details of the customer when customerid is given as input.
13. 14.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.
Create the following tables with the mapping given below.
14.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.
15. Write the Query statement for the following
a. Create a Student table (Regno, name, dept) and populate with data.
b. Create a view for CSE dept with the details of students of CSE dept.
c. Implement TCL commands with student table.
d.Write a PL/SQL program to find the details of the student when regno is given as input.
16. Create a database for Placement and Training cell.
Stud_details(regno, name, dept, percentage)
Company(companyID,name, noOfVacancy)
Training_Details(CourseID, name, Trainer)
Placed(regno, companyID,minSal)
i List the students who are eligible for recruitment in a particular company.
ii Display the student who has been placed with highest salary
iii Develop a PL/SQL exception that provides an alternate for not eligible students.
iv Write a PL/SQL program to print the factorial of given number.
17. Create a database for the following tables.
Hostel (hno, hname, type [boys/girls])
Menu (hno, day, breakfast, lunch, dinner)
Warden (wname, qual, hno)
Student (sid, sname, gender, year, hno)
i. Display the total number of girls and boys hostel in the college.
ii. Display the menu in the hostel ‘x’ on Tuesday.
iii. Display the number of wardens for each hostel.II.
iv. Write a PL/SQL program to print given number is Prime or not.
18. Consider the following database of student enrollment in courses and books adopted for that
course.
STUDENT(regno, name, major, bdate)
COURSE(courseno, cname, dept)
ENROLL(regno, courseno, sem, marks)
i. Display the total number of students register for more than two courses in a department
specified.
ii. Display the students who have secured the highest mark in each course
iii. List the youngest student of each course in all departments.
iv. Develop PL/SQL program that selects marks of a particular student in a specified
semester.

19. Create a database for Placement and Training cell.


Stud_details(regno, name, dept, percentage)
Company(companyID,name, noOfVacancy)
Training_Details(CourseID, name, Trainer)
Placed(regno, companyID,minSal)
v List the students who are eligible for recruitment in a particular company.
vi Display the student who has been placed with highest salary
vii Develop a PL/SQL exception that provides an alternate for not eligible students.
viii Write a PL/SQL program to print the factorial of given number.
20. Consider the following relational schema for a Loan database application:
Customer{Customer_id, Customer_name, Age, phone_no}
Loan{ Loan_id, Amount, Customer_id)}
i. Include the constraint on Loan_id that it starts with letter ‘L’.
ii. Display the list of the customer_ids and total Loan amount taken.
iii. Display the Customer_id and Customer_name who have taken less than two loans
v. Write a PL/SQL program to print the details of the customer when customerid is given as
input.
21. Create a Table as workers and the details are { S.No, Name, Designation, Branch }
Perform the following commands:
i. Alter the table by adding a column Salary
ii. Alter the table by modifying the column Name
iii. Describe the table employee
iv. Copy the table employee as emp
v. Truncate the table
vi. Delete the Second row from the table
vii. Drop the table.
viii. Write a PL/SQL program to print the given number is odd or even.
22. Create the following tables
student_details{register_no, student_name, DOB, address, city}
mark_details{register_no, mark1, mark2, mark3, total }
i. Display only those rows whose total ranges between 250 and 300.
ii. Drop the table mark_details and Delete the row whose register_no=161.
iii. Display all details whose names begins with 'a'.
iv. Write a PL/SQL program to print the details of the student when regno is given as input.
23. Create the student database with the following tables and do the following:
assessment(reg_no,name, mark1, mark2, mark3, total)
dept_details (dept_no, dept_name, location).
i. Using alter command drop the column location from the table dept_details.
ii. Display all dept_name along with dept_no.
iii. Drop the table dept_details.
i. Write a PL/SQL Trigger to verify the data before insertion on assessment table.
ii. Write a PL/SQL program to print the factorial of given number.
24. Create the Book database and do the following:
book(book_name,author_name,price,quantity).
i. Write a query to update the quantity by double in the table book.
ii. List all the book_name whose price is greater than those of book named "Database for
Dummies".
iii. Retrieve the list of author_name whose first letter is ’a’ along with the book_name and price.
iv.Write a PL/SQL Procedure to find the total number of books of same author.

25. Consider the following tables.


SAILOR(sid, sname, rating, age)
BOATS(bid, bname, colour)
RESERVES(sid, bid, day)
i. List the sailors in the descending order of their rating.
ii. List the sailors whose youngest sailor for each rating and who can vote.
iii. List the sailors who have reserved for both ‘RED’ and ‘GREEN’ boats.
iv. Create synonym for sailor table.
v. Create a PL / SQL Function that accepts SID and returns the name of sailor.
26. Create a Table as workers and the details are { S.No, Name, Designation, Branch }
Perform the following commands:
i. Alter the table by adding a column Salary
ii. Alter the table by modifying the column Name
iii. Describe the table employee
iv. Copy the table employee as emp
v. Truncate the table
vi. Delete the Second row from the table
vii. Drop the table.
viii. Write a PL/SQL program to print the Prime numbers
27. 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.
(e) Write a PL/SQL Program to print the given number is prime or not.
28. Consider the employee relational database, Where the primary keys are underlined.
Employee( employee_name, street, city)
Works ( employee_name, company_name, salary)
Company ( comapny_name, city)
Manages ( employee_name, manager_name)
a) Find all employees in the database who earn more than each employee of Small Bank
Corporation.
b) Assume that the companies may be located in several cities. Find all companies located
in every city in which Small Bank Corporation is located.
c) Give all managers of first Bank Corporation a 10 percent raise unless the salary
becomes greater than $100,000; in such cases, give only a 3 percent raise.
d) Write a PL/SQL program to print the odd or even number.

29. Create the Company database with the following tables and do the following:
Administration(employee_salary, development _cost, fund_amount, turn_over,bonus)
Emp_details (emp_no, emp_name, DOB, address, doj, mobile_no, dept_no, salary).
i. Calculate the total and average salary amount of the employees of each department.
ii. Display total salary spent for employees.
i. Develop a PL/SQL function to display total fund amount spent by the administration
department .

30. Consider the following relational schema for a Loan database application:
Customer{Customer_id, Customer_name, Age, phone_no}
Loan{ Loan_id, Amount, Customer_id)}
i. Include the constraint on Loan_id that it starts with letter ‘L’.
ii. Display the list of the customer_ids and total Loan amount taken.
iii. Display the Customer_id and Customer_name who have taken less than two loans
iv.Write a PL/SQL program to print the details of the customer when customerid is given as input.

31. Create a database for Placement and Training cell.


Stud_details(regno, name, dept, percentage)
Company(companyID,name, noOfVacancy)
Training_Details(CourseID, name, Trainer)
Placed(regno, companyID,minSal)
I. List the students who are eligible for recruitment in a particular company.
II. Display the student who has been placed with highest salary
III. Develop a PL/SQL exception that provides an alternate for not eligible students.
IV. Write a PL/SQL program to print the factorial of given number.

You might also like