-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7trigger.txt
28 lines (21 loc) · 893 Bytes
/
7trigger.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
create database lib;
use lib;
create table library(srno int(5),name varchar(40),author varchar(20),allowed_days int(5));
create table library_audit(srno int(5),old_all_days int(5),new_all_days int(5));
insert into library values (1,'Database Systems','Abc',10),
(2,'System Programming','xyz',20),
(3,'Computer Network & Internet','qwe',18),
(4,'Project Management','rty',24),
(5,'Python for Data Analysis','asd',12);
select * from library;
delimiter //
create trigger tr1
before update on library
for each row
begin
insert into library_audit values(new.srno,old.allowed_days,new.allowed_days);
end //
update library set allowed_days=15 where srno=1; //
update library set allowed_days=13 where srno=3; //
select * from library; //
select * from library_audit; //