当前位置:网站首页>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 .
边栏推荐
- Missing library while loading shared libraries: libisl so. 15: cannot open shared object file: No such file
- Create + register sub apps_ Define routes, global routes and sub routes
- How to find summer technical internship in junior year? Are you looking for a large company or a small company for technical internship?
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
- Word word word
- The data in servlet is transferred to JSP page, and the problem cannot be displayed using El expression ${}
- Machine learning process and method
- 8 free, HD, copyright free video material download websites are recommended
- Awk from getting started to being buried (2) understand the built-in variables and the use of variables in awk
- Kotlin middle process understanding and Practice (I)
猜你喜欢

What are the key points often asked in the redis interview

Create + register sub apps_ Define routes, global routes and sub routes

stm32F407-------DMA

内存池(内核角度理解new开辟空间的过程)

Wechat applet Development Tool Post net:: Err Proxy Connexion Problèmes d'agent défectueux

线程安全的单例模式

easyExcel

面试项目技术栈总结

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

Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
随机推荐
简单理解svg
stm32F407-------IIC通讯协议
Gbase 8C system table PG_ collation
Face recognition 6-face_ recognition_ Py based on OpenCV, face detection and real-time tracking using Haar cascade and Dlib Library
GBase 8c系统表-pg_collation
Method of removing webpage scroll bar and inner and outer margins
iptables 4层转发
Leetcode 183 Customers who never order (2022.07.02)
What are MySQL locks and classifications
stm32F407-------DMA
MySQL learning 03
What are the key points often asked in the redis interview
COM和CN
Packing and unpacking of JS
5. File operation
Y54. Chapter III kubernetes from introduction to mastery -- ingress (27)
Machine learning notes (constantly updating...)
Tongda OA homepage portal workbench
Explore the conversion between PX pixels and Pt pounds, mm and MM
Unrecognized SSL message, plaintext connection?