Documente Academic
Documente Profesional
Documente Cultură
KELANA JAYA
*** DO NOT OPEN THE QUESTION PAPER UNTIL YOU ARE TO LD TO DO SO ***
CONFIDENTIAL
SECTIONA There are SEVEN (7) questions in this part. Answer ALL questions. 1. a. What is a view?
(30 Marks)
(2 marks) b. Explain THREE (3) advantages of using a VIEW with examples. (6 marks) 2. List any TWO (2) advantages of using a database management system over the traditional file processing approach for storing and accessing data. (6 marks) What is the difference between dropping and truncating a table? (4 marks) 4. How is a PRIMARY KEY constraint different from a UNIQUE constraint? (2 marks) 5. What is the advantage of using a %TYPE method of declaring a variable in PL/SQL? (5 marks)
3.
7. What are the types of numbers that can be stored in each of the following datatype declarations?
a. b. c. NUMBER(5) NUMBER(5,2) NUMBER (3 marks)
SECTION B There is ONE (1) question in this section. Answer ALL questions. 1. Consider the following two tables: EMP TABLE Column Name EMPNO ENAME JOB MGR SAL COMM DEPTNO DataType NUMBER(4) VARCHAR2(20) CHAR(10) NUMBER(4) NUMBER(9,2) NUMBER(7,2) NUMBER(2)
(70 Marks)
REFERENCES DEPT(DEPTNO)
DEPT TABLE Column Name DEPTNO DNAME LOC DataType NUMBER(2) VARCHAR2(20) VARCHAR2(20) Constraint PRIMARY KEY NOT NULL
CONFIDENTIAL
a.
Create the above two tables (along with the appropriate constraints). (6 marks)
b.
Select the employee number, employee name, job, department number and departme nt name of th all employees who have joined the organization before 30 September 1981. (5 marks) Create a new table named DESIGNATIONS which contains only the empno, ename and job columns of the original emp table. (3 marks) Insert all rows in table designation from table emp for which the department number is either 10, 20 or 30. (3 marks) Give a salary increment of 20% to all the employees in department number 20. (4 marks)
c.
d.
e.
f.
List the employee name, salary, PF, HRA, DA and gross; order the result in ascending order of gross. PF is 10% of salary, HRA is 50% of salary , DA is 30% of salary and gross = sal + HRA PF DA. (3 marks) Create a read-only view named MANAGERS of all employees who are managers . (3 marks)
g.
h.
For each department, list the number of people having the same designation. (4 marks)
i.
List the total salary, maximum and minimum salary and the average salary of employees job wise for department number 10 and 20. (5 marks) List all the employee names and their managers. (5 marks)
j.
k.
List the name of the employee drawing the highest salary. (4 marks)
l.
m. Update the salary of all employees to the maximum salary in the corresponding department. (5 marks) n. Delete the records of employees whose salary is below the average salary in the department. (5 marks) Write a PL/SQL procedure to delete an employee from the EMP table. The steps of the procedure are as follows: a. The employee number is passed to the procedure as a parameter. b. The employee number and name of the employee in the deleted record are saved in another table called FORMER_EMP. c. The record is deleted from the EMP table. d. The delete_date column in the FORMER_EMP table is updated with the current system date. (10 marks) *** END OF QUESTION PAPER ***
o.