当前位置:网站首页>Gbase 8C trigger (I)
Gbase 8C trigger (I)
2022-07-03 02:22:00 【Dazhuang twelve】
Trigger functions can use most of the available procedural languages , Include PL/pgSQL、PL/Tcl、PL/Perl and PL/Python. Trigger is a mechanism that database provides programmers and data analysts to ensure data integrity , It is a special stored procedure related to data table events . The execution of the trigger is not called by the program , There is no need to open it manually , It is triggered by events on the data table , When users add to a data table 、 Delete 、 When the operation is changed, it will be activated to execute .
A trigger declares that the database should automatically execute a special function when performing a specific type of operation . Triggers can be attached to tables ( Partition or no partition )、 Views and external tables .
On tables and external tables , Triggers can be defined as INSERT、UPDATE or DELETE The operation is performed before or after , Can be for each SQL The statement is executed once or once for each modified row .UPDATE Triggers can be further set to target only UPDATE Of the statement SET Clause starting from a specific column . Triggers can also be TRUNCATE Statement trigger . If a trigger event occurs , The trigger function will be called at the appropriate event to handle the event .
On the view , Triggers can be defined to replace INSERT、UPDATE or DELETE Operation execution .INSTEAD OF The trigger triggers once for each row in the view that needs to be modified . The responsibility of the trigger function is to make necessary changes to the underlying basic table , And when appropriate, return the modified row for display in the view . Triggers on views can also be defined for each SQL Statement is executed once , stay INSERT\UPDATE or DELETE Before or after the operation .
The trigger function must be defined before the trigger itself is created . Trigger function must be defined as a function without parameters , And the return type is trigger( Trigger function is passed through a special TriggerData Structure as its input , Not in the form of ordinary function parameters ).
Once a suitable trigger function is created , You can use CREATE TRIGGER Set up triggers . The same trigger function can be used for multiple triggers .
GBase 8c Provide triggers for each row and each statement at the same time . For a trigger per row , For each line modified by the statement that triggers the trigger, the trigger function will be called once . contrary , A trigger of each statement is called only once for its triggering statement , No matter how many lines the statement affects . Specially , A statement that does not affect any rows will still result in the execution of any available triggers per statement . These two types of triggers are sometimes called row level triggers and statement level triggers respectively .TRUNCATE Triggers on can only be defined at the statement level , Instead of defining each line .
Triggers can also depend on whether they are before the operation 、 Trigger later , Or be triggered to replace the operation to classify . They refer to BEFORE trigger 、AFTER Triggers and INSTEAD OF trigger . Sentence level BEFORE Triggers are triggered before the statement starts doing anything , And statement level AFTER Triggers are triggered after the statement finishes everything . These trigger types can be defined in the table 、 View or external table . Row level BEFORE Triggers are triggered before each row is manipulated , And row level AFTER The trigger is triggered after the end of the statement ( But at any statement level AFTER Before trigger ). These trigger types can only be defined on non partitioned tables and external tables , Cannot be defined on a view .INSTEAD OF Triggers can only be defined on views , And can only be defined as row level ; They immediately trigger for each row in the view that is identified as needing to be manipulated .
边栏推荐
- UDP receive queue and multiple initialization test
- Comment communiquer avec Huawei Cloud IOT via le Protocole mqtt
- Current situation and future of Web3 in various countries
- Gbase 8C system table PG_ conversion
- GBase 8c触发器(二)
- Deep learning notes (constantly updating...)
- GBase 8c系统表-pg_amop
- Awk from getting started to getting into the ground (3) the built-in functions printf and print of awk realize formatted printing
- JS的装箱和拆箱
- What are MySQL locks and classifications
猜你喜欢

详细些介绍如何通过MQTT协议和华为云物联网进行通信
![[Flutter] dart: class; abstract class; factory; Class, abstract class, factory constructor](/img/06/ab333a4752de27eae2dd937cf579e2.png)
[Flutter] dart: class; abstract class; factory; Class, abstract class, factory constructor

Awk from introduction to earth (0) overview of awk
![[shutter] shutter debugging (debugging fallback function | debug method of viewing variables in debugging | console information)](/img/66/0fda43da0d36fc0c9277ca86ece252.jpg)
[shutter] shutter debugging (debugging fallback function | debug method of viewing variables in debugging | console information)

Coroutinecontext in kotlin

返回一个树形结构数据

Use go language to realize try{}catch{}finally

Producer consumer model based on thread pool (including blocking queue)

elastic stack

Servlet中数据传到JSP页面使用el表达式${}无法显示问题
随机推荐
The use of Flink CDC mongodb and the implementation of Flink SQL parsing complex nested JSON data in monggo
线程安全的单例模式
《上市风云》荐书——唯勇气最可贵
Word word word
5.文件操作
通达OA 首页门户工作台
GBase 8c 创建用户/角色 示例二
[Yu Yue education] reference materials of love psychology of China University of mining and technology
GBase 8c系统表pg_cast
GBase 8c 函数/存储过程参数(一)
Introduce in detail how to communicate with Huawei cloud IOT through mqtt protocol
Return a tree structure data
Face recognition 6-face_ recognition_ Py based on OpenCV, face detection and real-time tracking using Haar cascade and Dlib Library
Detailed introduction to the deployment and usage of the Nacos registry
SPI机制
Qt之QComboBox添加QCheckBox(下拉列表框插入复选框,含源码+注释)
创建+注册 子应用_定义路由,全局路由与子路由
Compréhension simple de SVG
COM and cn
easyExcel