怎么在sql2000查找触发器
发布网友
发布时间:2022-05-29 09:56
我来回答
共1个回答
热心网友
时间:2023-10-15 05:15
最基本的触发器是针对表的insert、update、delete这三种操作来的。触发器可以建立在表上,也可以建立在视图上。建立在表上的触发器会在表内容发生改变时触发。建立在视图上的触发器会在视图内容改变时触发。注意,视图触发器仅会在明确对视图进行操作的sql语句执行时才会触发,当基本表的内容发生改变而引起视图内容变化时,不会触发视图触发器。
下面是建立表触发器的代码:
create
or
replace
trigger
tg_e_contact
before
update
or
insert
or
delete
on
e_contact
for
each
row
begin
if
inserting
then
insert
into
e_contact@gaac.world
values
(:new.telephone,
:new.employeeid,
:new.status);
else
if
updating
then
update
e_contact@gaac.world
s
set
s.telephone
=
:new.telephone,
s.employeeid
=
:new.employeeid,
s.status
=
:new.status
where
s.employeeid
=
:old.employeeid;
else
if
deleting
then
delete
from
e_contact@gaac.world
s
where
s.employeeid
=
:old.employeeid;
end
if;
end
if;
end
if;
end;
下面是建立视图触发器的代码:(注意里面的instead
of)
create
or
replace
trigger
tg_e_contact
before
instead
of
update
or
instead
of
insert
or
instead
of
delete
on
e_contact
for
each
row
begin
if
inserting
then
insert
into
e_contact@gaac.world
values
(:new.telephone,
:new.employeeid,
:new.status);
else
if
updating
then
update
e_contact@gaac.world
s
set
s.telephone
=
:new.telephone,
s.employeeid
=
:new.employeeid,
s.status
=
:new.status
where
s.employeeid
=
:old.employeeid;
else
if
deleting
then
delete
from
e_contact@gaac.world
s
where
s.employeeid
=
:old.employeeid;
end
if;
end
if;
end
if;
end;