当前位置:网站首页>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 .
边栏推荐
- Deep learning notes (constantly updating...)
- 通达OA v12流程中心
- How do it students find short-term internships? Which is better, short-term internship or long-term internship?
- 微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題
- Solution for processing overtime orders (Overtime unpaid)
- GBase 8c系统表pg_database
- Cfdiv2 fixed point guessing- (interval answer two points)
- The Sandbox阐释对元宇宙平台的愿景
- How to deal with cache hot key in redis
- Face recognition 6-face_ recognition_ Py based on OpenCV, face detection and real-time tracking using Haar cascade and Dlib Library
猜你喜欢
Producer consumer model based on thread pool (including blocking queue)
SPI mechanism
Recommendation letter of "listing situation" -- courage is the most valuable
What are the key points often asked in the redis interview
4. 类和对象
stm32F407-------ADC
Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
返回一个树形结构数据
Servlet中数据传到JSP页面使用el表达式${}无法显示问题
easyExcel
随机推荐
Recommendation letter of "listing situation" -- courage is the most valuable
《上市风云》荐书——唯勇气最可贵
我的创作纪念日
The use of Flink CDC mongodb and the implementation of Flink SQL parsing complex nested JSON data in monggo
微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題
Gbase 8C system table PG_ authid
QT qcombobox add qccheckbox (drop-down list box insert check box, including source code + comments)
Awk from getting started to being buried (2) understand the built-in variables and the use of variables in awk
GBase 8c系统表-pg_auth_members
GBase 8c系统表-pg_class
GBase 8c 创建用户/角色 示例二
awk从入门到入土(0)awk概述
Gbase 8C system table PG_ database
Return a tree structure data
Awk from entry to burial (1) awk first meeting
Awk from introduction to earth (0) overview of awk
stm32F407-------ADC
8 free, HD, copyright free video material download websites are recommended
Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
返回一个树形结构数据