当前位置:网站首页>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间路由(讲解+验证)
- Use the PIP command to switch between different mirror sources
- 【QT】无法在QT创建者中打开包含文件pcap.h(C1083)
- A Competitive Swarm Optimizer for Large Scale Optimization
- 杂谈:最近好多朋友谈出国……
- MySQL2
- (2022杭电多校三)1009.Package Delivery(贪心)
- Port forwarding summary
- 软件测试十大必问面试题(附答案和解析)
- ShowDoc漏洞学习——CNVD-2020-26585(任意文件上传)
猜你喜欢
随机推荐
Basic functions and collections of guava
(2022 Hangdian multi school III) 1009.package delivery (greedy)
想sink 到 redis-hash 里面 把 对象的属性和值都写进去 ,大佬们有Demo 吗?
Analysis of query results using both left join on and where in MySQL
adb指令整理
flink cdc 抽取oracle的数据,会不断的占用oracle的内存吗,最后引发ora-040
Want to sink into redis hash and write in the attributes and values of the object. Do the bosses have a demo?
Introduction to network -- overview of VLAN and trunk
Perl: 将要执行的外部命令拆分为多行
Pytorch notes: td3
sql-labs SQL注入平台-第1关Less-1 GET - Error based - Single quotes - String(基于错误的GET单引号字符型注入)
2022-07-25 Gu Yujia's study notes
Port forwarding summary
网络入门——vlan及trunk概述
(2022牛客多校三)J-Journey(dijkstra)
Usage of string class
在kettle使用循环来处理表中的数据
【QT】capture.obj:-1: error: LNK2019: 无法解析的外部符号 __imp_htons(解决方法)
Word wrap: break word line feed is compatible with browsers
Excuse me, MySQL timestamp (6) using flick SQL is null. Is there a way to deal with this








