4sem CE246 DBMS Practical List 2019-20
4sem CE246 DBMS Practical List 2019-20
Sr.
No. Aim of the practical
1. Find the names of all the students whose total credits are greater than 100
2. Find the course id and grades of all courses taken by any student named 'Tanaka'
3. Find the ID and name of instructors who have taught a course in the Comp. Sci.
department, even if they are themselves not from the Comp. Sci. department. To
test this query, make sure you add appropriate data, and include the corresponding
insert statements along with your query.
4. Find the courses which are offered in both 'Fall' and 'Spring' semester (not
necessarily in the same year).
Write the following simple SQL Queries on the University Schema Railway Schema -
Bottom Up Approach
1. Find pairs of stations (station codes) that have a track (direct connection) with
distance less than 20Kms between them.
2. Find the IDs of all the trains which have a stop at THANE
3. Find the names of all trains that start at MUMBAI.
4. List all the stations in order of visit by the train 'CST-AMR_LOCAL'.
5. Find the name of the trains which have stop at Thane, before the 6th station in the
route of the train.
5 To apply the concept of aggregating data using group functions and single raw
functions.
7 Displaying data from multiple tables – Apply inner , outer, natural join must be use.
Write a PL-SQL block for checking weather a given year is a Leap year or not
Create an employees table that is a replica of the emp table. Add a new column, stars, of
varchar2 data type and length of 50 to the employees table for storing asterisk (*).
Create a pl/sql block that rewards an employee by appending an asterisk in the stars column
for every rs1000/- of the employee’s salary. For example, if the employee has a salary amount
of rs8000/-, the string of asterisks should contain eight asterisks. If the employee has a salary
amount of rs12500/-, the string of asterisks should contain 13 asterisks.
Update the stars column for the employee with the string of asterisks.
12 To perform the concept of cursor
1. Display all the information of emp table using %rowtype.
2. Create a pl/sql block that does the following: in a pl/sql block, retrieve the name,
salary, and manager id of the employees working in the particular department. Take
department id from user. If the salary of the employee is less than 1000 and if the
manager id is either 7902 or 7839, display the message <<last_name>> due for a raise.
Otherwise, display the message <<last_name>> not due for a raise.
13 To perform the concept of function and procedure
To update the salary of employee specified by empid. If record exist then update the salary
otherwise display appropriate message. Write a function as well as procedure for updating
salary.
14 To perform the concept of exception handler
Write a PL/SQL block that will accept the employee code, amount and operation. Based on
specified operation amount is added or deducted from salary of said employee. Use user
defined exception handler for handling the exception.
15 To perform the concept of trigger
Write a pl/sql block to update the salary where deptno is 10. Generate trigger that will store
the original record in other table before updation take place
16 To perform the concept of package
1. Create a package specification and package body called EMP_PACK that contains
your NEW_EMP procedure as a public construct, and your VALID_DEPTID function
as a private construct. (You can save the specification and body into separate files.)
2. Invoke the NEW_EMP procedure, using 40 as a department number. Because the
dept_no 40 does not exist in the DEPT table, you should get an error message as
specified in the exception handler of your procedure.
3. Invoke the NEW_EMP procedure, using an existing department ID 80.