Вы находитесь на странице: 1из 11

Problem 1: Create Two tables Department & Department 1 as per given below data &


Problem 2: Create a Cursor (simple_cur) under stored procedure (SP_CUR) to display

the department name by passing the department id during procedure call- Use Table
Department (Table 1).
Problem 3: Create & execute before insert trigger B_I on table Department to ensure
that if a user wants to insert new record in department table, the new location will be
stored as INDIA automatically, means you will insert only Dept_ID & Dept_Name &
Location will be auto triggered as INDIA.

Problem 4: Create & execute after insert trigger A_I on table Department to insert
new data in to Department table & same data (Dept_ID) will auto inserted to table
department1 with edit time.
Problem 5: Create & execute after update trigger A_U on table Department to update
department information. For example you want to update Dept_ID =1005 for HR dept in
department table & these Changes must be reflected into both tables. Means you will
update only department table & Department1 will be updated automatically. (In this
operation the OLD id will be exist in the department1 table, to remove that ID you can
run a delete query with in the same begin-end block).
Problem 6: Create & execute after delete trigger A_D on table Department to delete
the record of HR department & changes must be reflected into both tables. Means you
will delete the record from the table Department & same record will be deleted from
department1 automatically.
*Display all the triggers in DBMS2017 & Drop Them

Date: 24/03/17
1. Create a Function AddTwoNo (to add two numbers) that take input from the user.

2. Drop AddTwoNo function.

3. Create a Stored Procedure Create_Table to create a table- Empl as per given

below declaration.

4. Create & Call a Stored Procedure Insert_Record to insert data into table Empl by
stored procedure as mentioned below:
5. Display table Empl.

6. Create & Call a Stored Procedure Update_Record to update data into table Empl
Set Emp_Name as ABC whose Emp_ID id 1001.

7. Create & Call a Stored Procedure Select_Record to display the table Empl

8. Create & Call a Stored Procedure Simple_Proc to count the number of employees
using out keyword.

9. Display the all functions and procedures in DBMS_2017 database.

10. Drop a Stored Procedure

Create two tables as per given below structure under DBMS17 _CSD21 & insert data as
mentioned below:
Structure forTable1: Employee

Attribute(Field/Colum Data Declaration

n) Name
Emp_ID int(5)-primary key
Emp_Name Varchar(20)-not null
Manager_ID Int(5)
Dept_ID Int(5)

Structure for table 2: Department

Attribute(Field/Colum Data Declaration
n) Name
Dept_ID int(5)-primary key
Dept_Name Varchar(20)-not null
Location Varchar(20)


Note: - Fill data into both tables as given below

Table1: Employe

Emp_ Emp_Nam Manager Dept_

ID e _ID ID Table 2: Department
1001 Alex Bert 1003 2001
1002 John 2002 Dept_I Dept_Na Location
Methew D me
1003 Mery Lee 1006 2002 2001 Washingt
1004 Kim John 1004 2003 Finance
1005 Reyan Fert 1008 2003
on Union:
2002 HR California
1006 Luther 2009 2003 Finance Alabama Perform a
Warn 2004 Logistics Houston union
operation to get the details of 2005 HR Chicago employees
-> Emp_ID, Emp_Name and the 2006 Washingt employees
works in HR department with their on Dept_ID.


Select all details from both tables i.e. Employe-Emp_Name & Manager_ID with the help of
(a). Create an index First_Index on the table employee on filed Emp_Name in
descending order.

(b). Display the information of First_Index

(c). Display the data of First_Index - Select index


(d).Drop the First_Index.