17,377
社区成员
发帖
与我相关
我的任务
分享
SQL>
SQL> create table test(id int , name varchar(10));
Table created
SQL> create table test_bak(id int , name varchar(10));
Table created
SQL> create trigger test_up
2 before update on test
3 for each row
4 begin
5 insert into test_bak(id , name)values(:old.id , :old.name);
6 end ;
7 /
Trigger created
SQL> begin
2 insert into test(id,name) values(1,'lisi');
3 insert into test(id,name) values(2,'zhang');
4 commit ;
5 end;
6 /
PL/SQL procedure successfully completed
SQL> update test set name = 'zhangsan' where id = 2 ;
1 row updated
SQL> select * from test ;
ID NAME
--------------------------------------- ----------
1 lisi
2 zhangsan
SQL> select * from test_bak ;
ID NAME
--------------------------------------- ----------
2 zhang
SQL> drop table test purge ;
Table dropped
SQL> drop table test_bak purge ;
Table dropped
SQL>