当前位置:网站首页>Examples of Oracle triggers
Examples of Oracle triggers
2022-07-27 07:28:00 【hawanglc】
This article demonstrates oracle Use of triggers , For a rainy day
-- Create a table , In the future, we need to create triggers on this table
create table baby_test
(id number(20),
name varchar(50),
birthday date,
login_date timestamp
);
-- Create a table that holds trigger operations
-- drop table baby_test_log;
create table baby_test_log
(id number(20),
name varchar(50),
insert_date date default sysdate,
operate varchar2(50)
);
-- Create a trigger . When the baby_test Table data insertion , When you modify and delete , towards baby_test_log Insert data
CREATE OR REPLACE TRIGGER trg_baby_test BEFORE
INSERT OR UPDATE or delete ON baby_test
FOR EACH ROW DECLARE
-- local variables here
BEGIN
CASE
WHEN inserting THEN
INSERT INTO baby_test_log (
id,
name,
operate
) VALUES (
:new.id,
:new.name,
'inserting'
);
WHEN updating('name') THEN
INSERT INTO baby_test_log (
id,
name,
operate
) VALUES (
:old.id,
:old.name,
'updating name'
);
WHEN deleting THEN
INSERT INTO baby_test_log (
id,
name,
operate
) VALUES (
:old.id,
:old.name,
'deleting'
);
END CASE;
END;
-- Test triggers
insert into baby_test
select 1,'baby',to_date('19990101','yyyymmdd'), sysdate from dual;
select * from baby_test;
update baby_test
set name = 'hugh'
where id = 1;
delete from baby_test where id = 1;
-- View the results of the trigger
select * from baby_test_log;边栏推荐
- vlan间路由(讲解+验证)
- centos7中关闭oracle服务自动启动的功能
- 单元测试系统化讲解之Mockito
- docker安装MySQL8.0.28
- C语言实现猜数字小游戏项目实战(基于srand函数、rand函数,Switch语句、while循环、if条件判据等)
- The difference between critical section (the code that accesses critical resources in each thread) and mutex (mutex between processes, shared memory, virtual address)
- 简单的轮播图
- Use reflection to dynamically modify annotation attributes of @excel
- UI gesture actions of uiautomator common classes
- C language pthread_ cleanup_ Push() and pthread_ cleanup_ Pop() function (used for the resource cleaning task after the termination action in the critical resource program segment to avoid deadlock. T
猜你喜欢
随机推荐
Py2exe QT interface style becomes Win98 solution
vlan间路由(讲解+验证)
C语言 pthread_cleanup_push()和pthread_cleanup_pop()函数(用于临界资源程序段中发生终止动作后的资源清理任务,以免造成死锁,临界区资源一般上锁)
杂谈:跟女儿聊为啥要学好文化课
在kettle使用循环来处理表中的数据
Bash: 创建返回布尔类型值的函数
functools模块
[Vani has a date] tail on rainy days
A Competitive Swarm Optimizer for Large Scale Optimization
Codeforces Round #787 (Div. 3)(7/7)
在rhel8上使用soci连接oracle和postgresql和sqlite
使用pip命令切换不同的镜像源
ShowDoc漏洞学习——CNVD-2020-26585(任意文件上传)
C4D云渲染平台选哪家合作?
Use the PIP command to switch between different mirror sources
(2022杭电多校三)1009.Package Delivery(贪心)
Pan Aimin, chairman of instruction set, attended the 2022 ecug con to speak for China's technical forces
零号培训平台课程-1、SQL注入基础
【QT】无法在QT创建者中打开包含文件pcap.h(C1083)
Pg_relation_size 问题









