当前位置:网站首页>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 .
边栏推荐
- Trial setup and use of idea GoLand development tool
- GBase 8c系统表-pg_attribute
- Cancellation of collaboration in kotlin, side effects of cancellation and overtime tasks
- [Yu Yue education] reference materials of chemical experiment safety knowledge of University of science and technology of China
- 【CodeForces】CF1338A - Powered Addition【二进制】
- How to deal with cache hot key in redis
- Wechat applet Development Tool Post net:: Err Proxy Connexion Problèmes d'agent défectueux
- 【教程】chrome關閉跨域策略cors、samesite,跨域帶上cookie
- Explore the conversion between PX pixels and Pt pounds, mm and MM
- Exception handling in kotlin process
猜你喜欢
![[shutter] bottom navigation bar implementation (bottomnavigationbar bottom navigation bar | bottomnavigationbaritem navigation bar entry | pageview)](/img/41/2413af283e8f1db5d20ea845527175.gif)
[shutter] bottom navigation bar implementation (bottomnavigationbar bottom navigation bar | bottomnavigationbaritem navigation bar entry | pageview)

微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題

面试项目技术栈总结

基于线程池的生产者消费者模型(含阻塞队列)

PyTorch 卷积网络正则化 DropBlock

The use of Flink CDC mongodb and the implementation of Flink SQL parsing complex nested JSON data in monggo

4. Classes and objects

Solution for processing overtime orders (Overtime unpaid)

easyExcel

What are MySQL locks and classifications
随机推荐
GBase 8c 触发器(一)
502 (bad gateway) causes and Solutions
GBase 8c系统表-pg_authid
Gbase 8C system table PG_ collation
COM and cn
Memory pool (understand the process of new developing space from the perspective of kernel)
require.context
Comment communiquer avec Huawei Cloud IOT via le Protocole mqtt
Job object of collaboration in kotlin
What are MySQL locks and classifications
Trial setup and use of idea GoLand development tool
RestCloud ETL 跨库数据聚合运算
创建+注册 子应用_定义路由,全局路由与子路由
Packing and unpacking of JS
人脸识别6- face_recognition_py-基于OpenCV使用Haar级联与dlib库进行人脸检测及实时跟踪
GBase 8c系统表-pg_auth_members
Distributed transaction solution
Thread safe singleton mode
Coroutinecontext in kotlin
GBase 8c 函数/存储过程参数(一)