0% found this document useful (0 votes)
11 views12 pages

DBMS Viva Questions

The document outlines various aims and practice questions related to SQL commands, including DDL, DML, joins, subqueries, set operations, views, control structures, exception handling, functions, procedures, and triggers. It also includes viva questions that test understanding of key concepts in SQL and PL/SQL. Each section provides practical exercises to apply knowledge and assess comprehension of database management and programming.

Uploaded by

kashayap211
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)
11 views12 pages

DBMS Viva Questions

The document outlines various aims and practice questions related to SQL commands, including DDL, DML, joins, subqueries, set operations, views, control structures, exception handling, functions, procedures, and triggers. It also includes viva questions that test understanding of key concepts in SQL and PL/SQL. Each section provides practical exercises to apply knowledge and assess comprehension of database management and programming.

Uploaded by

kashayap211
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/ 12

Aim: Experiments based on DDL commands

PRACTICE QUESTIONS:

1. Create a table EMPLOYEE with following schema:


(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name,Job_id , Salary)

2. Add a new column; HIREDATE to the existing relation.

3. Change the datatype of JOB_ID from char to varchar2.

4. Change the name of column/field Emp_no to E_no.

5. Modify the column width of the job field of emp table

6. Drop the "Employee" table from the database.

7. Truncate the data from the "Orders" table, keeping the table structure intact.

VIVA - QUESTIONS:
Que1. What is a NULL value and how does it differ from a zero value?

Que2. What are SQL Constraints?

Que3. What are different Data Types in SQL?

Que4. What is the difference between CHAR and VARCHAR?

Que 5. What is Difference between NUMBER, INTEGER and INT DataTypes?

Aim: Apply the integrity constraints

VIVA – QUESTIONS:

Que1. What are different Constraints in SQL?


Que2. What is the purpose of Null Constraint?
Que 3. What is the function of Reference Constraint?
Que 4. What is Index Constraint?
Que 5. What is the purpose of Default Constraint?
Aim: Experiments based on basic DML commands

PRACTICE QUESTIONS:

Create a table EMPLOYEE with following schema:


(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name,Job_id , Salary)

Write SQL queries for following question:

1. Insert aleast 5 rows in the table.

2. Display all the information of EMP table.

3. Display the record of each employee who works in department D10.

4. Update the city of Emp_no-12 with current city as Nagpur.

5. Display the details of Employee who works in department MECH.

6. Delete the email_id of employee James.

7. Display the complete record of employees working in SALES Department

VIVA- QUESTIONS:

Que1. What is the use of SELECT command?

Que2. What is the purpose of WHERE clause?

Ques3. Which language supports SELECT command?

Que4. How to select entire content of a table.

Que5. What are different DML commands?

Que6. What is the purpose of DELETE command?

Que7. What is difference between ALTER and UPDATE commands?


Aim: Write the queries for implementing Built-in functions, GROUP BY, HAVING and
ORDER BY.
PRACTICE QUESTIONS:

Schema:

Sales

product_id sales_date quantity_sold

1. Calculate the total quantity sold for each product, but only show products with a
total quantity sold greater than or equal to 25.

2. Count the number of sales for each product and sales date, but only show those
with more than one sale on any date.

3. Find products that have never sold more than 10 units in a single sale.

4. Calculate the total quantity sold for each product and show only those with an
average quantity sold less than or equal to 15 units.

VIVA – QUESTIONS:

Que1. Explain HAVING and GROUPBY clause.

Que2. What are the syntax of HAVING clause?

Que3. What is the Syntax of GROUPBY clause?

Que4. Difference between HAVING AND WHERE clauses.

Que5. Difference between ORDERBY and GROUPBY clause.


Aim: Write the queries to implement the joins

PRACTICE QUESTIONS:

Consider the following schema:

Sailors (sid, sname, rating,


age) Boats (bid, bname,
color) Reserves (sid, bid,
day(date))

1. Find all information of sailors who have reserved boat number 101.
2. Find the name of boat reserved by Bob.
3. Find the names of sailors who have reserved a red boat, and list in the order of age.
4. Find the names of sailors who have reserved at least one boat.
5. Find the ids and names of sailors who have reserved two different boats on the same day.
6. Find the ids of sailors who have reserved a red boat or a green boat.
7. Find the name and the age of the youngest sailor.
8. Count the number of different sailor names.
9. Find the average age of sailors for each rating level.
10. Find the average age of sailors for each rating level that has at least two sailors.

VIVA - QUESTIONS:

Que1. What is a JOIN Operation?

Que2. Difference between JOIN and PRODUCT operation?

Que3. What are different types of JOIN Operations?

Que4. Difference between RIGHT OUTER and LEFT OUTER join?

Que5. What is an INNER join?


Aim: Write the queries to implement the Subqueries.

PRACTICE QUESTIONS:

1. Retrieve the details of students who have scored the highest marks in each subject.
2. Find the courses taken by students from a specific city.
3. Retrieve the names of students who have taken all available courses.
4. Find the courses with the highest enrolment.
5. Get the list of students who have scored lower than the average score in all subjects.
6. Retrieve the names of students who have not registered for a specific course.
7. Find the courses with no registered students.
8. Retrieve the names of students who have registered for all courses in a specific
department.

VIVA - QUESTIONS:

1. What is a subquery, and how is it different from a regular query?


2. How can subqueries be used to filter data in a SELECT statement?
3. Explain the difference between a scalar subquery and a multiple-row subquery.

4. What is a correlated subquery, and when would you use it?

5. How can subqueries be used to perform calculations or aggregations?


Aim: Write the queries to implement the Set Operations.

PRACTICE QUESTIONS:

1. Retrieve a list of student names from the "students" table, excluding those present in
the "new_students" table.
2. Combine the names of students from the "students" and "new_students" tables,
including duplicates.
3. Get the names of students who are either in the "students" table or in the
"new_students" table, but not in both.
4. Retrieve a list of student names who have registered for at least one course from
either the "students" or "new_students" tables.
5. Combine the student names from the "students" and "new_students" tables,
including duplicates, and sort the result in ascending order.
6. Retrieve the student names from the "students" table who have not registered
for any courses.
7. Get the names of students who are present in both the "students" table and
the "new_students" table, including duplicates.

VIVA - QUESTIONS:

1. What is the difference between the UNION and UNION ALL operations in DBMS?
2. How does the INTERSECT operation work in DBMS, and what is its purpose?
3. Explain the EXCEPT (or MINUS) operation in DBMS and provide an example.
4. Can you combine multiple set operations in a single query? If so, provide an example.
5. What happens if the SELECT statements in a set operation have different column
names or incompatible data types?
Aim: Write the queries to create the views and queries based on views

PRACTICE QUESTIONS:

Table: Students

Student ID Student Name Department ID Grade


1 John Doe 1 A
2 Jane Smith 2 B
3 Mike Johnson 1 A-

Table: Departments

Department ID Department Name


1 Computer Science
2 Mathematics
3 Physics

1. Write an SQL query to create a view named "Student Grades" that retrieves the Student
ID, Student Name, and Grade from the Students table.

2. Write an SQL query to retrieve the contents of the "Student Grades" view created in the
previous question.

3. Write an SQL query to create a view named "Top Students" that retrieves the Student ID,
Student Name, and Grade of students who have a grade of "A".

4. Write an SQL query to retrieve the contents of the "Top Students" view created in the
previous question.

5. Write an SQL query to create a view named "Department Summary" that retrieves the
Department ID, Department Name, and the total number of students in each department.

6. Write an SQL query to retrieve the contents of the "Department Summary" view created
in the previous question.

7. Write an SQL query to create a view named "Top Scoring Departments" that retrieves
the Department ID, Department Name, and the average grade of students in each department,
sorted in descending order by the average grade.
VIVA - QUESTIONS:

Que1. What is a view?

Que2. How we create a view?

Que3. What is the purpose of creating a VIEW?

Que4. What is the syntax of creating a VIEW?

Que5. How many VIEWS can be created for a table?

Aim: Demonstrate the concept of Control Structures.


PRACTICE QUESTIONS:

1. Write a PL/SQL block that checks if a variable named "age" is greater


than or equal to 18. If it is, display the message "You are eligible for
voting."

2. Write a PL/SQL block that checks if a number variable named "score"


is greater than 90. If it is, display the message "Congratulations, you
passed!" Otherwise, display the message "Sorry, you did not pass."

3. Write a PL/SQL block that uses a FOR loop to display the numbers
from 1 to 10 on separate lines.

4. Write a PL/SQL block that uses a WHILE loop to display the even
numbers between 1 and 20 on separate lines.

5. Write a PL/SQL block that uses a CASE statement to determine the


grade based on a variable named "percentage." Display the
corresponding grade message (e.g., "A", "B", "C", etc.) depending on
the percentage value.
VIVA - QUESTIONS:

1) How many nested IF clauses can be included within an IF clause? ...

2) Which structure executes a sequence of statements repeatedly as


long as a condition holds true?

3) What is the maximum number of ELSE clauses that can be included


in an IF clause that is not nested?

4) Which statements execute a sequence of statements multiple times?

Aim: Demonstrate the concept of Exception Handling.

PRACTICE QUESTIONS:

1. Write a PL/SQL block that raises an exception if a variable named


"balance" is negative. Handle the exception by displaying a custom error
message.

2. Write a PL/SQL block that includes a division operation. Handle the


"ZERO_DIVIDE" exception using the WHEN OTHERS clause to display a
user-friendly message.

3. Define a user-defined exception named "InvalidInputException." Write a


PL/SQL block that raises this exception if a variable named "input" is not
within the range of 1 to 100.

4. Define an exception named "CustomException." Associate it with the


Oracle error code "ORA- 00001" using the EXCEPTION_INIT pragma.
Write a PL/SQL block that handles the "CustomException" and displays a
specific error message for that error code.

5. Write a PL/SQL block that includes a subprogram. Inside the subprogram,


raise an exception. Handle the exception in the main block and display an
appropriate message indicating the exception's occurrence.
VIVA - QUESTIONS:

1. In PL/SQL, a warning or error condition is called an exception.

2. For which Exception, if a SELECT statement attempts to retrieve data


based on its conditions, this exception is raised when no rows satisfy the
SELECT criteria?

3. What is the difference between Errors and Exceptions?

4. How do you handle exceptions?

5. How do you differentiate between errors in SQL and PL/SQL?

Aim: Demonstrate the concept of Function and Procedures


PRACTICE QUESTIONS:

1. Write a PL/SQL code snippet to create a function named "calculate_area"


that accepts the radius of a circle as a parameter and returns the calculated
area of the circle.

2. Write a PL/SQL code snippet to create a procedure named


"insert_employee" that inserts a new employee record into an "Employees"
table. The procedure should accept parameters such as employee name, ID,
and department.

3. Create two functions named "calculate_area" that accept different


parameters. One function should calculate the area of a rectangle based on
its length and width, while the other function should calculate the area of a
square based on its side length.

4. Create a procedure named "get_employee_name" that accepts an


employee ID as input and returns the corresponding employee name as an
OUT parameter.
5. Create a function named "divide_numbers" that accepts two numbers as
parameters and returns the result of dividing the first number by the second
number. Handle the "ZERO_DIVIDE" exception and return NULL if the
second number is 0.

VIVA - QUESTIONS:

1. What are subprograms in PL/SQL and what are the advantages of


subprograms?

2. What are the types of subprograms in PL/SQL?

3. What is a Stored Procedure in PL/SQL?

4. What is Stored Function?

5. What is the difference between anonymous block and subprograms?

6. What are the modes for passing parameters to stored Procedure or Function?

Aim: Demonstrate the concept of Triggers


PRACTICE QUESTIONS:

1. Write a PL/SQL trigger that fires before inserting a new record into
a table named "Employees." The trigger should automatically set the
"created_date" column to the current date and time.

2. Create a PL/SQL trigger that fires after updating the "Salary"


column in a table named "Employees." The trigger should log the old
and new values of the salary in an audit table named "Salary_Audit."

3. Write a PL/SQL trigger that fires instead of deleting a record from a


table named "Orders." The trigger should perform additional
validation checks and prevent the deletion if specific conditions are
not met.
4. Create a PL/SQL compound trigger that fires before and after
updating the "Quantity" column in a table named "Inventory." The
trigger should log the old and new values of the quantity in separate
audit tables named "Quantity_Before_Update" and
"Quantity_After_Update."

5. Write a PL/SQL trigger that fires after inserting, updating, or


deleting records from both the "Customers" and "Orders" tables. The
trigger should perform a specific action whenever a change occurs in
either of the tables.

VIVA - QUESTIONS:

1. What is a triggering event?

2. Types of trigger based on triggering event?

3. What are some use cases of Triggers?

4. Difference between Triggers and Constraints?

5. What is a DML Trigger?

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