Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Dbms Answers All - Haam's Community

Download as pdf or txt
Download as pdf or txt
You are on page 1of 55

DBMS WORKSHEETS ANSWERS ALL ( 1 TO 10)

HAAM’S COMMUNITY

JOIN TELEGRAM GROUP - https://t.me/HAAMSCOMMUNITY

WORKSHEET -1.1
Q1. Create a table called Employee with the following structure.
Name Type
Empno Number
Ename Varchar2(10)
Job Varchar2(10)
Mgr Number
Sal Number
a. Add a column commission with domain to the Employee table.
b. Insert any five records into the table.
c. Update the column details of job
d. Rename the column of Employ table using alter command.
e. Delete the employee whose Empno is 105.

CODE -

create table employee(

empno number,
ename varchar2(10),
job varchar2(10),
mgr number,

sal number

);

alter table employee

add commission varchar(10);


insert into employee
values(110,'yana','clerk',5402,3000,100); insert
into employee
values(105,'avi','manager',5112,5000,200);
insert into employee
values(169,'nitin','salesman',5407,10000,300);
insert into employee
values(180,'sahil','designer',5445,8000,150);
insert into employee
values(147,'kartik','analyst',5123,3000,200);
update employee

set job='salesman'
select * from employee; alter
table employee rename
column job to post;select *
from employee; delete from
employee where
empno=105;

select * from employee;

a. Add a column commission with domain to the


Employeetable.
b. Insert any five records into the table.
c. Update the column details of job.
d. Rename the column of Employ table using
altercommand.
e. Delete the employee whose Empno is 105.
Q2- Create a table called Employee with the following structure.
Name Type
Empno Number
Ename Varchar2(10)
Job Varchar2(10)
Mgr Number
Sal Number

Code :
create table employee
(
empno number,
ename varchar2(10),
job varchar2(10),
mgr number,
sal number
);
alter table employee
add commission varchar(10);
insert into employee
values(110,'yana','clerk',5402,3000,100);
insert into employee
values(105,'avi','manager',5112,5000,200);
insert into employee
values(169,'nitin','salesman',5407,10000,300);
insert into employee
values(180,'sahil','designer',5445,8000,150);
insert into employee
values(147,'kartik','analyst',5123,3000,200);
update employee
set job='salesman'
select * from employee;
alter table employee
rename column job to post;
select * from employee;
delete from employee
where empno=105;
select * from employee;

a. Add a column commission with domain to the Employee


table.

b. Insert any five records into the table.


c. Update the column details of job.
d. Rename the column of Employ table using alter command.
e. Delete the employee whose Empno is 105.
Q3 -Create department table with the following
structure. Name Type
Deptno Number
Deptname Varchar2(10)
location Varchar2(10)
Code :
CREATE TABLE
department (
deptno NUMBER,
deptname
VARCHAR2(10),
location
VARCHAR2(10)
);
ALTER TABLE department
ADD designation VARCHAR2(10)
INSERT INTO department
VALUES(1,'electrical','chandigarh','student');
INSERT INTO department VALUES(3,'cse','patiala','student');
INSERT INTO department VALUES(4,'ca','delhi','student');
INSERT INTO department VALUES(9,'mba','mumbai','student');
INSERT INTO department VALUES(7,'civil','hydrabad','student');
SELECT *
FROM department;
SELECT deptno FROM
department
GROUP BY
deptno;
UPDATE department
SET location = 'chennai'
WHERE deptno = 9;
DELETE FROM department
WHERE deptno = 7;

a.Add column designation to the department table.

b. Insert values into the table


c. List the records of dept table grouped by deptno.

d. Update the record where deptno is 9.

e. Delete any column data from the table.


Q-4- Create table EMP with the following
description : Name Type
EMPNO NOT NULL
NUMBER(4) ENAME
VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(3)
AGE NUMBER(3)
ESAL NUMBER

create table EMP(


EMPNO NUMBER(4) NOT
NULL, ENAME
VARCHAR(10),
JOB VARCHAR(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(3),
AGE NUMBER(3),
ESAL NUMBER
);
desc EMP;

insert into EMP values(2173, 'yana', 'developer' , 7902, '14/feb/2018' ,1560.50,


26.87, 20 ,24, 2000 );
insert into EMP values(2221, 'avi', 'manager' , 7902, '12/oct/2016'
,2290.50, 66.34, 10 ,23, 3000 );
insert into EMP values(2803, 'ashish', 'salesman' , 7578, '16/jan/2015'
,3250, 100, 20 ,24, 3500 );
insert into EMP values(1014, 'kartik', 'designer' , 7566, '25/dec/2017' ,4000,
112.53, 25 ,20, 4000 );
insert into EMP values(1015, 'nitin', 'analyst' , 7789, '29/aug/2019' ,3500,
76.89, 10 ,20, 3500 );

select * from EMP;

select ENAME,SAL from EMP where SAL>=1500 and

SAL<=3500 ; select ENAME,MGR from EMP where MGR

in(7902,7566,7789) ; select * from EMP where DEPTNO

in(10,20);

a. Get the description EMP table.

b. List all employees details.


c. List all employee names and their salaries, whose salary lies
between 1500/- and 3500/- both inclusive.

d. List all employee names and their manager whose manager is 7902
or 7566 0r 7789.
e. List all employees who belongs to the department 10 or 20.
WORKSHEET -1.2

Q 1 - create table emp with attributes (eid number,ename


varchar2(10),age number,salary number);

CODE :

create table emp(E_Id number,E_name varchar(20),Age number,Salary


number);

insert into emp values(101,'Anu',22,9000);

insert into emp values(102,'Shane',29,8000);

insert into emp values(103,'Rohan',34,6000);

insert into emp values(104,'Scott',44,10000);

insert into emp values(105,'Tiger',35,8000);

insert into emp values(106,'Alex',27,7000);

insert into emp values(107,'Abhi',29,8000);

select count(E_name) as number_of_employee_names from emp;

select sum(Age) from emp;

select Salary from emp group by Salary;


select Salary from emp order by Salary;

select E_name,Salary from emp order by Salary desc;

a. Count number of employee names from employee table.

b. Display the Sum of age employee table.


c. Find grouped salaries of employees (group by clause).

d. Find salaries of employee in Ascending Order (order by clause).

e. Find salaries of employee in Descending Order.


Q 2 - Consider a relation Employee with following attributes:
Name Null Type
-------------------------------- ----------------------- -------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(3)
AGE NUMBER(3)
ESAL NUMBER(10)

CODE :

create table Employee(Name varchar(20),EMPNO number(4) not


null,ENAME varchar2(10),JOB varchar2(9),MGR number(4),HIERDATE
date,SAL number(7,2),COMM number(7,2),DEPTNO number(3),AGE
number(3),ESAL number(10));
insert into Employee
values('YANA',100,'ISHIKA','ENGINNER',10,'21/JUNE/2005',12345.76,78
90.88,100,23,7654);
insert into Employee
values('SMITA',102,'SIMRAN','MANAGER',20,'21/JULY/2005',34567.89,8
388.86,101,24,8844);
insert into Employee
values('MANISH',103,'ASHISH','TEACHER',30,'21/AUG/2005',45678.09,7
747.88,102,25,84943);
insert into Employee
values('SOHAM',104,'RADHIKA','MANAGER',20,'21/Jun/2005',56789.10,2
345.64,101,26,98474);
insert into Employee
values('ROHAN',105,'ASTHA','TECAHER',30,'21/Jul/2005',67890.21,23455
.67,102,27,74774);
insert into Employee
values('SHINCHAN',106,'','DOREAMI',,'ENGINEER',10,'21/Aug/2005',789
01.32,34555.78,100,28,66474);
insert into Employee
values('SHAAN',107,'SIMMI','MANAGER',20,'21/Sep/2005',89012.43,2345
5.89,101,29,774443);

select MIN(SAL),MAX(SAL),AVG(SAL) from Employee;

select MAX(SAL)-MIN(SAL) AS DIFFERENCE_IN_SALARIES from


Employee;

select NAME,SAL from Employee where SAL>(select MIN(SAL) from


EMPLOYEE) and JOB like 'M%';

select SUM(SAL),JOB from Employee GROUP BY JOB;

select MIN(SAL),MGR from EMPLOYEE GROUP BY MGR;

a. List minimum , maximum , average salaries of employee.


b. What is the difference between maximum and minimum salaries
of employees in the organization?

c. Display all employee names and salary whose salary is greater


than minimum salary of the company and job title starts with ‘M’.
d. Display total salary spent for each job category.

e. Display lowest paid employee details under each manager.


WORKSHEET -1.3

Q1 - Write a PL/SQL program to find odd or


even number.
Code :
DECLARE
n NUMBER := 0725;
r NUMBER;
BEGIN
r := MOD(n, 2);
IF r = 0 THEN
dbms_output.Put_line('Even');
ELSE
dbms_output.Put_line('Odd');
END IF;
END;

Output :
Q2- Write a PL/SQL program to find area and
perimeter of rectangle.
Code :
DECLARE
l NUMBER(4, 2) := 3;
b NUMBER(4, 2) := 3;
a NUMBER(4, 2);
p NUMBER(4, 2);
BEGIN
a := l * b;
p := 2 * (l + b);
dbms_output.Put_line('Area of the rectangle is '
|| a);
dbms_output.Put_line('Perimeter of the rectangle is '
|| p);
END;
Output :

WORKSHEET -2.1

Q1 - Write a program in PL/SQL to print the prime


numbers between 1 to 100.
CODE :
DECLARE
i NUMBER(3);
j NUMBER(3);
BEGIN
dbms_output.Put_line('The prime numbers are:');
dbms_output.new_line;
i := 2;
LOOP
j := 2;
LOOP
EXIT WHEN( ( MOD(i, j) = 0 )
OR ( j = i ) );
j := j + 1;
END LOOP;
IF( j = i )THEN
dbms_output.Put(i||' ');

END IF;
i := i + 1;
exit WHEN i = 100;
END LOOP;
dbms_output.new_line;
END;
/

OUTPUT :

Q2- Write a PL/SQL program to check whether a


date falls on weekend i.e. SATURDAY or SUNDAY.
CODE :
Declare
testday varchar2(15);
Begin
select To_Char(sysdate,'DAY') into testday from dual;
If testday in ('SATURDAY','SUNDAY') THEN
dbms_output.new_line;
DBMS_OUTPUT.PUT_LINE('Its WeekEnd');
Else
dbms_output.new_line;
DBMS_OUTPUT.PUT_LINE('Got to WORK today');
End If;
End;
/

OUTPUT :
WORKSHEET -2.3

Q1- Write a PL/SQL block to display the last name of manager, and their
departments for a particular city, using parameters with a default value in explicit cursor.

CODE))
OUTPUT)
Q2–
Write a block in PL/SQL to print the specific number
of
rows from a table. CODE :

create table employees(


first_name varchar(20),
last_name varchar(20), salary number(20) );
insert into employees values('Mansi','Singh',50000);
insert into employees
values('Anu','Kesarvani',30000);
insert into employees values('Drishti','Singh',80000);
insert into employees
values('Rohan','Sharma',20000);
insert into employees
values('Roshan','Sharma',100000);
insert into employees
values('Ankita','Dwivedi',90000);
insert into employees values('Dhruv','Tuli',1200000);
insert into employees values('Nikhil','Berry',10000);

insert into employees


values('Dhaval','Mehta',100000);
insert into employees
values('Shivam','Singh',150000);

DECLARE
CURSOR emp_cur IS
SELECT first_name,last_name, salary FROM
employees
WHERE ROWNUM < 8
ORDER BY first_name;

emp_fname employees.first_name%TYPE;
emp_lname employees.last_name%TYPE;
emp_sal employees.salary%TYPE;
BEGIN
OPEN emp_cur;
LOOP
FETCH emp_cur INTO emp_fname,emp_lname,
emp_sal;
IF emp_cur%NOTFOUND THEN
EXIT;
ELSE
DBMS_OUTPUT.PUT_LINE
(rpad('Name: ' || emp_fname||' '|| emp_lname ,30)||
'salary: ' ||
emp_sal);
END IF;
END LOOP;
END;

WORKSHEET – 2.4
Q1–
Aim/Overview of the practical:
Write a query to create a view that finds the
salesman who has the customer with the
highest
order at least 3 times on a day.
Relation1: Customer
customer_id | cust_name | city | grade |
salesman_id
-------------+----------------+------------+-------+-------
------
3002 | Nick Rimando | New York | 100 | 5001
3007 | Brad Davis | New York | 200 | 5001
3005 | Graham Zusi | California | 200 | 5002
3008 | Julian Green | London | 300 | 5002
3004 | Fabian Johnson | Paris | 300 | 5006
3009 | Geoff Cameron | Berlin | 100 | 5003
3003 | Jozy Altidor | Moscow | 200 | 5007
3001 | Brad Guzan | London | | 5005
Relation2: elitsalesman
salesman_id | name | city | commission
-------------+------------+----------+------------ 5001
| James Hoog | New York | 0.15
5002 | Nail Knite | Paris | 0.13
5005 | Pit Alex | London | 0.11
5006 | Mc Lyon | Paris | 0.14

5007 | Paul Adam | Rome | 0.13 5003 | Lauson


Hen |
San Jose | 0.12

CODE:-
create table Customer (customer_id
int,cust_name varchar(100),city
varchar(50),grade int,salesman_id int); insert
into Customer
values(3002,'Nick Rimando','New
York',100,5001); insert into Customer
values(3007,'Brad Davis','New York',200,5001);
insert into Customer
values(3005,'Graham
Zusi','California',200,5002); insert into Customer
values(3008,'Julian Green','london',300,5002);
insert into Customer
values(3004,'Fabian Johnson','Paris',300,5006);
insert into Customer
values(3009,'Geoff Cameron','Berlin',100,5003);
insert into Customer
values(3003,'Jozy Altidor','Moscow',200,5007);
insert into Customer
values(3001,'Brad guzan','London',' ',5005);
select * from Customer;
create table elitSalesman (salesman_id int,name
varchar(100),city
varchar(50),commission float); insert into
elitSalesman
values(5001,'James Hoog','New York',0.15);
insert into elitSalesman
values(5002,'Nail Knite','Paris',0.13); insert into
elitSalesman
values(5005,'Pit Alex','London',0.11); insert into
elitSalesman
values(5006,'Mc Lyon','Paris',0.14); insert into
elitSalesman
values(5007,'Paul Adam','Rome',0.13); insert into
elitSalesman
values(5003,'Lauson Hen','San Jose',0.12); select
* from elitSalesman;
create table Orders (order_no int,purch_amt
float,ord_date
varchar(10),customer_id int,salesman_id int);
insert into Orders

values(70001,150.5,'2012-10-05',3005,5007);
insert into Orders
values(70009,270.65,'2012-09-10',3001,5005);
insert into Orders
values(70002,65.26,'2012-10-05',3002,5001);
insert into Orders
values(70004,110.5,'2012-08-17',3009,5003);
insert into Orders
values(70007,948.5,'2012-09-10',3005,5002);
insert into Orders
values(70005,2400.6,'2012-07-27',3007,5001);
insert into Orders
values(70008,5760,'2012-09-10',3002,5001);
insert into Orders
values(70010,1983.43,'2012-10-10',3004,5006);
insert into Orders
values(70003,2480.4,'2012-10-10',3009,5003);
insert into Orders
values(70012,250.45,'2012-06-27',3008,5002);
insert into Orders
values(70011,75.29,'2012-08-17',3003,5007);
insert into Orders
values(70013,3045.6,'2012-04-25',3002,5001);
select * from orders;
CREATE VIEW sHighestOrders3
AS SELECT a.name
FROM elitsalesman a, orders b
WHERE a.salesman_id = b.salesman_id
AND b.purch_amt =
(SELECT MAX (purch_amt)
FROM orders c
WHERE c.ord_date = b.ord_date)
GROUP BY a.name
HAVING count(*) >= 3; select
* from sHighestOrders3;

Q2–
Consider the following relations:
Salesman
salesman_id | name | city | commission
-------------+------------+----------+------------ 5001
| James Hoog | New York | 0.15
5002 | Nail Knite | Paris | 0.13
5005 | Pit Alex | London | 0.11
5006 | Mc Lyon | Paris | 0.14
5007 | Paul Adam | Rome | 0.13
5003 | Lauson Hen | San Jose | 0.12
Customer
customer_id | cust_name | city | grade |
salesman_id
-------------+----------------+------------+-------+---------
----
3002 | Nick Rimando | New York | 100 | 5001
3007 | Brad Davis | New York | 200 | 5001
3005 | Graham Zusi | California | 200 | 5002
3008 | Julian Green | London | 300 | 5002
3004 | Fabian Johnson | Paris | 300 | 5006
3009 | Geoff Cameron | Berlin | 100 | 5003
3003 | Jozy Altidor | Moscow | 200 | 5007
3001 | Brad Guzan | London | | 5005

Orders ord_no purch_amt ord_date customer_id


salesman_id
---------- ---------- ---------- ----------- -----------
70001 150.5 2012-10-05 3005 5002
70009 270.65 2012-09-10 3001 5005
70002 65.26 2012-10-05 3002 5001
70004 110.5 2012-08-17 3009 5003
70007 948.5 2012-09-10 3005 5002
70005 2400.6 2012-07-27 3007 5001
70008 5760 2012-09-10 3002 5001
70010 1983.43 2012-10-10 3004 5006
70003 2480.4 2012-10-10 3009 5003
70012 250.45 2012-06-27 3008 5002
70011 75.29 2012-08-17 3003 5007
70013 3045.6 2012-04-25 3002 5001
Write a query to create a view that shows for
each order the salesman and customer by name.

CODE:
create table salesman(
salesman_id number(20),
name varchar(225), city
varchar(225),
commission float(20))
;

insert into salesman values( 5001 ,'James


Hoog','New York' ,0.15)
;

insert into salesman values( 5002,'Nail


Knite','Paris' ,0.13)
;

insert into salesman values(5005,'Pit


Alex','London',0.11 )
;
insert into salesman values( 5006,'Mc
Lyon','Paris',0.14 )
;

insert into salesman values( 5007,'Paul


Adam','Rome',0.13 )
;

insert into salesman values(5003,'Lauson


Hen','San Jose',0.12)
;

CREATE VIEW newyorkstaff


AS SELECT *
FROM salesman

WHERE city = 'New York';

select * from newyorkstaff;

CREATE VIEW salesown


AS SELECT salesman_id, name, city
FROM salesman
;
select * from salesown;
WORKSHEET – 3.1
Q1–
Create a procedure or function to calculate electricity
bill as per the following criteria:
For first 100 units: Rs. 5 per unit
For 101-150 units: Rs. 7 per unit
For 151-300 units: Rs. 7.50 per unit
For 301 onward units: Rs. 8 per unit

CODE:
CREATE OR REPLACE PROCEDURE E_bill(unit in
number,net out number) is
BEGIN
--drop procedure E_bill
--for first 100 unit :RS 5 per unit
if (unit between 0 and 100) then

net:= unit*5;

--for first 101 - 150 unit :RS 7 per unit


elsif (unit between 101 and 150) then
net:= unit*7;

--for first 151 - 300 unit :RS 7.5 per unit


elsif (unit between 151 and 300) then
net:= unit*7.5;

--for first 301 above unit :RS 8 per unit


elsif (unit<=301) then
net:= unit*8;
end if;

END;
/

Declare
---INPUT UNIT
unit1 number:=200;
total number;

BEGIN
E_bill(unit1,total);
dbms_output.put_line('FOR FIRST ' || unit1 || ' UNITS ' || '
ELECTRICITY BILL IS :' || total);
END;

OUTPUT:

Q2–
Write a procedure to calculate factorial of a number entered by
user.

CODE -
CREATE or replace PROCEDURE fact(n number) as
f number:=1;
begin
for i in 1..n
loop
f:=f*i;
end loop;
dbms_output.put_line('factorial = ' || f);
end;
/

exec fact(5)

OUTPUT -

WORKSHEET – 3.2
Q1–
Create a package circle having the following functions:
1. Area of circle.
2. Circumference of circle.
Radius is to be passed as argument to both the functions to
calculate values.

CODE:
create or replace package circle AS

function area(r IN number, ar OUT number) return number;

procedure circum(r IN number, cir OUT number);

end;

create or replace package body circle AS

function area(r in number, ar out number) return number AS

begin

ar:=3.14*r*r;

return (ar);

end area;

procedure circum(r in number, cir out number) AS

begin

cir:=2*3.14*r;

end circum;

end;
declare

r number:=10;

a number;

c number;

begin

a:=circle.area(r,a);

circle.circum(r,c);

dbms_output.put_line('Area is ' || a);

dbms_output.put_line('Circumference is '|| c);

end;

OUTPUT –

Q2–
Create a package named as INFO which contains procedure that is
passed a student's identification number and return student's full
name and phone number from the student table to the calling
program and function, pass a department number to it. If the
DEPT table does not contain the department number, return a
FALSE value otherwise return a TRUE value. Print the
appropriate message to the calling program.

CODE:
CREATE TABLE student (ID INTEGER,FNAME
VARCHAR(20),LNAME VARCHAR(20),GENDER CHAR(1),dept
number(20),p_no number(10));
INSERT INTO student
VALUES(101,'ROHIT','SINGH','M',20,9867543210);
INSERT INTO student
VALUES(102,'VISHAL','PANDEY','M',21,8998899809);
INSERT INTO student
VALUES(103,'PIHU','KUMARI','M',22,9080706050);
INSERT INTO student
VALUES(104,'RAHUL','SINHA','F',23,9192939495);
INSERT INTO student
VALUES(105,'HARRY','POTTER','M',24,8765432198);

----------DROP TABLE student--------------

CREATE OR REPLACE PACKAGE stu AS


PROCEDURE stu_info(s_id student.id%type);
END stu;

-----------------------------------------------------------

CREATE OR REPLACE PACKAGE BODY stu AS

PROCEDURE stu_info(s_id student.id%type) IS


s_fname student.fname%TYPE;
s_p_no student.p_no%TYPE;

BEGIN

SELECT fname INTO s_fname


FROM student
WHERE id = s_id;
dbms_output.put_line('NAME : '|| s_fname);
SELECT p_no INTO s_p_no
FROM student
WHERE id = s_id;
dbms_output.put_line('PHONE NO : '|| s_p_no);

END stu_info;
END stu;

--------------------------find department exist or not--------------------------


----

CREATE OR REPLACE PACKAGE stu1 AS


PROCEDURE stu_dept(s_dept student.dept%type);
END stu1;

-----------------------------------package body----------------------------------
-

CREATE OR REPLACE PACKAGE BODY stu1 AS

PROCEDURE stu_dept(s_dept student.dept%type) IS

s_fname student.fname%TYPE;

BEGIN

if s_dept=10 then
dbms_output.put_line('TRUE ');
else
dbms_output.put_line(' FALSE ');
end if;

END stu_dept;
END stu1;

----------------------------------student info------------------------------------

declare
sid number;
begin
sid:=102;
stu.stu_info(sid);
end;

------------------------------------department-----------------------------------
declare
sdept number;
begin
sdept:=20;
stu1.stu_dept(sdept);
end;

OUTPUT :

SS1 –

SS2 –
WORKSHEET – 3.3
Q1–
Create a row trigger which ensures that whenever salary is updated in the
emp table, then some message is displayed to the user and if new salary is
lesser than old salary display the difference between both the salaries.

CODE:
create table emp(sno number(10), fname varchar(20), eid number(10),salary
number(20));
insert into emp values(001,'JAMES',101,20000);
select * from emp

create or replace trigger emp_sal


after update on emp
for each row

Declare
sal_diff number;
Begin

dbms_output.put_line('Salary Updated');
if(:new.salary<:old.salary) then
sal_diff:= :old.salary-:new.salary;
dbms_output.put_line('DIFFERENCE : ' || sal_diff);
end if;

end;
/

----------------------------
update emp set salary=salary-500 where sno=001;

OUTPUT:
Q2 –
Apply a trigger on relation client (sno, fname, lname, eid, and password) on
attributes fname and password after/before delete or update these columns.
The trigger should insert the old or deleted values from both these columns
into a new table client1.

CODE:
create table client(sno number(10), fname varchar(20), eid number(10),passwrd
varchar(20));
insert into client values(001,'JAMES',101,'james101');
select * from client

----------------
create table client1(sno1 number(10), fname1 varchar(20), eid1
number(10),passwrd1 varchar(20));
--drop table client
select * from client1
---------------------
create or replace trigger client_trigg
before delete or update on client
for each row
Begin
insert into client1 values(:old.sno,:old.fname,:old.eid,:old.passwrd) ;
end;

update client set passwrd='james20' where sno=001;

delete from client where sno=001;


OUTPUT:

Update client set passwrd='james20' where sno=001;

You might also like