计算机二级什么时候考| 日进斗金什么意思| 一什么蔷薇| 华五行属什么| 牛头马面指什么生肖| 天蝎男和什么星座最配| 贝字旁与什么有关| 6.19是什么日子| 蝶窦囊肿是什么病| 白带发黄有异味用什么药| 牙疼吃什么药| 吃完饭就想睡觉是什么原因| 不满是什么意思| 宫颈糜烂用什么药好得快| 耳朵里面痒用什么药| 三教九流代表什么生肖| 睑腺炎是什么原因造成| 女人出黄汗是什么原因| 月经量多是什么原因| 副高是什么意思| 精油是什么| 腰肌劳损贴什么膏药| 牙齿涂氟是什么意思| 声音的高低叫什么| 林黛玉和贾宝玉是什么关系| 卡司是什么意思| 一直鼻塞是什么原因| 潘氏试验阳性说明什么| 舌头发热是什么原因| 食铁兽是什么动物| 脾肾阳虚吃什么药最好| 芦荟胶有什么作用| 甲亢挂什么科| 298什么意思| 扳机点是什么意思| 人生苦短什么意思| 驻村是什么意思| 属猪男配什么属相最好| 酸枣仁配什么治疗失眠| 怀疑是什么意思| 莲子心泡水喝有什么功效和作用| 血糖高什么症状| 什么叶子| 看什么| 一个口一个且念什么| 三加一是什么意思| 冠脉ct和冠脉造影有什么区别| 对立面是什么意思| shiraz是什么名字红酒| 唐筛是检查什么| 为什么下雨会打雷| 马来酸曲美布汀片什么时候吃| 二月什么星座| 拉尿有泡泡是什么原因| 血小板低是什么原因引起的| 朱允炆为什么不杀朱棣| 脖子皮肤黑是什么原因| 落英缤纷是什么意思| 葡萄又什么又什么| 孕酮低什么原因| 什么叫吐槽| 胳膊麻是什么原因| 80年五行属什么| 孕妇吃什么水果好对胎儿好| 玻璃是什么垃圾| 人活着意义是什么| 双开什么意思| 双肾囊肿什么意思| 轻微食物中毒吃什么药| 神经性皮炎用什么药膏| 维生素b12有什么作用| 尿潴留是什么病| 对牛弹琴告诉我们什么道理| 狗狗中毒了用什么办法可以解毒| 什么是动脉瘤| 三个降号是什么调| 呼吸道感染用什么药| 23年属什么生肖| 气虚血瘀吃什么中成药| 什么他妈的叫他妈的惊喜| 维生素h的作用及功能主治是什么| 清分日期是什么意思| 尿常规隐血弱阳性什么意思| 什么样的房子风水好| 迅速的反义词是什么| 梅毒是什么样的| 前胸后背疼是什么病| 为什么肚子会隐隐作痛| 脚踝疼挂什么科| 防弹衣是由什么材料制成的| 21三体高风险是什么原因造成的| 肺气泡吃什么药| 黑色上衣配什么颜色的裤子| 调月经吃什么药好| 双性人什么意思| 尖锐湿疣是什么病| 螯合是什么意思| 口巴读什么| 吃海鲜喝什么酒| 肝着是什么意思| 产妇吃什么水果| 蚊子喜欢咬什么人| 眼睛充血用什么眼药水好| 小姑娘月经推迟不来什么原因| 体感温度是什么意思| 中指和无名指发麻是什么原因| 什么是医疗器械| 主人杯是什么意思| 新生儿前面头发稀少是什么原因| ut是什么| 自缢是什么意思| 什么的蔷薇| 17楼五行属什么| 属鸡的和什么属相最配| 空调出现pl是什么意思| 自叹不如什么意思| 老年人吃什么| 泡沫尿吃什么药| 无限极是干什么的| 冷得什么| 标本是什么意思| 夹心饼干是什么意思| 老年人吃什么水果对身体好| 以貌取人是什么意思| 小脑是控制什么的| 嘴巴里长泡是什么原因| 大什么一什么| 笑哭表情什么意思| zzy是什么意思| 自给自足是什么意思| 检查前列腺需要做什么检查| 咳喘是什么原因| 黑桃a是什么酒| ipa啤酒是指什么| 自我为中心是什么意思| 小三阳是什么| 多吃香蕉有什么好处和坏处| 风起云涌是什么意思| 陆地上最重的动物是什么| 狗癣用什么药最有效| 喝什么茶可以减肥| 黄麻是什么| 绿色的大便是什么原因| 1114是什么星座| 房产证和土地证有什么区别| 梦见租房子住是什么意思| 非你不可什么意思| 杰字属于五行属什么| 女人耳鸣是什么前兆| 蟠桃为什么是扁的| nuskin是什么牌子| 阳虚是什么意思| 孩子流黄鼻涕吃什么药效果好| 狐媚是什么意思| 尿液发红是什么原因| 脚底起水泡是什么原因| 三七粉什么人不适合吃| 女人腰疼是什么原因引起的| 虾滑可以做什么菜| 足三里在什么位置| 吃什么胸大| 色盲色弱是什么意思| 内分泌科看什么| 孕初期吃什么对胎儿好| ckd是什么意思| 月经期间吃西瓜有什么影响| 壑是什么字| 卡介苗是什么| 什么病不能吃玉米| 瓜子脸剪什么发型好看| 71年属什么生肖| 眼眶疼是什么原因| 抗hbc阳性是什么意思| 为什么午觉睡醒后头疼| moschino是什么品牌| 复查是什么意思| 致爱是什么意思| 尿常规白细胞高是什么原因| 月经周期短是什么原因| 金鱼藻属于什么植物| 诟病是什么意思| 胸口闷是什么原因| 79属什么生肖| 西晋之后是什么朝代| z是什么火车| 女生发个wink什么意思| 血管是什么颜色的| 福州有什么好玩的地方| chd医学上是什么意思| 脑梗吃什么药可以恢复的快| 属猪与什么属相相合| 手麻挂什么科| 被子植物是什么| 肝炎吃什么药最好| 恍然大悟是什么意思| 唇珠是什么| 宝玑手表是什么档次| 梦见好多黄鳝是什么意思| 疝气挂什么科| 自残是什么心理| 鱿鱼和什么炒好吃| 81年属什么| 头孢是什么| 近亲结婚生的孩子会得什么病| 羊下面是什么生肖| 舌头上有齿痕是什么原因| 石蛋是什么| 傻白甜什么意思| 脚气什么症状| 重庆五行属什么| 寡糖是什么糖| messi是什么意思| sku是什么| 薄荷泡水喝有什么好处| 脑血栓适合吃什么水果| cif是什么意思| 吃什么能减肥最快还能减全身| 黑色屎是什么原因| 心悸是什么原因造成的| 肝有问题会出现什么症状| 1993属什么| 鸡毛信是什么意思| 为什么爱放屁| 什么鱼刺少| 为什么吐后反而舒服了| 什么动物不怕热| ct是检查什么的| 拉痢疾是什么症状| 手术室为什么那么冷| 人活着到底有什么意义| 槟榔为什么上瘾| yet什么意思| 脱发缺少什么维生素| 眼睛像什么| 血压低吃什么药见效快| 透明人什么意思| 什么样的星星| 看心理医生挂什么科| 红米是什么米| 下面有味道用什么药| 棕色和什么颜色搭配好看| 蓝色预警是什么级别| 脾大是什么原因| 吃什么能降尿酸| 芒果不能和什么水果一起吃| 乙肝表面抗体弱阳性是什么意思| 百草枯什么味道| 同房子宫疼痛什么原因| 掌中宝是什么部位| 农历六月十二是什么日子| 男人肝火旺吃什么药| nova是什么牌子| anti是什么意思| 耘是什么意思| 糯叽叽什么意思| 单从属于什么茶| 什么情况下需要做肠镜检查| 四方草地是什么生肖| 蒙脱石散是什么成分| 双子座的幸运花是什么| 大放厥词是什么意思| 夏季喝什么茶| 无休止是什么意思| 脑供血不足吃什么中成药好| 百度
Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: 18 / devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

睡莲为什么不开花

Name

CREATE TRIGGER -- define a new trigger

Synopsis

百度 韩昇教授《唐太宗治国风云录》一书的出版适逢其时,以其特有的人文历史写作风格,融合了社会科学式的追问,向我们全面展示了唐太宗独特的治国理政治思想,深刻揭示了唐太宗如何通过制度建设这一“本根”使国家走向盛世“茂荣”之道。
CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] }
    ON table [ FOR [ EACH ] { ROW | STATEMENT } ]
    [ WHEN ( condition ) ]
    EXECUTE PROCEDURE function_name ( arguments )

Description

CREATE TRIGGER creates a new trigger. The trigger will be associated with the specified table and will execute the specified function function_name when certain events occur.

The trigger can be specified to fire either before the operation is attempted on a row (before constraints are checked and the INSERT, UPDATE, or DELETE is attempted) or after the operation has completed (after constraints are checked and the INSERT, UPDATE, or DELETE has completed). If the trigger fires before the event, the trigger can skip the operation for the current row, or change the row being inserted (for INSERT and UPDATE operations only). If the trigger fires after the event, all changes, including the effects of other triggers, are "visible" to the trigger.

A trigger that is marked FOR EACH ROW is called once for every row that the operation modifies. For example, a DELETE that affects 10 rows will cause any ON DELETE triggers on the target relation to be called 10 separate times, once for each deleted row. In contrast, a trigger that is marked FOR EACH STATEMENT only executes once for any given operation, regardless of how many rows it modifies (in particular, an operation that modifies zero rows will still result in the execution of any applicable FOR EACH STATEMENT triggers).

In addition, triggers may be defined to fire for a TRUNCATE, though only FOR EACH STATEMENT.

Also, a trigger definition can specify a Boolean WHEN condition, which will be tested to see whether the trigger should be fired. In row-level triggers the WHEN condition can examine the old and/or new values of columns of the row. Statement-level triggers can also have WHEN conditions, although the feature is not so useful for them since the condition cannot refer to any values in the table.

If multiple triggers of the same kind are defined for the same event, they will be fired in alphabetical order by name.

SELECT does not modify any rows so you cannot create SELECT triggers. Rules and views are more appropriate in such cases.

Refer to Chapter 36 for more information about triggers.

Parameters

name

The name to give the new trigger. This must be distinct from the name of any other trigger for the same table.

BEFORE
AFTER

Determines whether the function is called before or after the event.

event

One of INSERT, UPDATE, DELETE, or TRUNCATE; this specifies the event that will fire the trigger. Multiple events can be specified using OR.

For UPDATE triggers, it is possible to specify a list of columns using this syntax:

UPDATE OF column_name1 [, column_name2 ... ]

The trigger will only fire if at least one of the listed columns is mentioned as a target of the update.

table

The name (optionally schema-qualified) of the table the trigger is for.

FOR EACH ROW
FOR EACH STATEMENT

This specifies whether the trigger procedure should be fired once for every row affected by the trigger event, or just once per SQL statement. If neither is specified, FOR EACH STATEMENT is the default.

condition

A Boolean expression that determines whether the trigger function will actually be executed. If WHEN is specified, the function will only be called if the condition returns true. In FOR EACH ROW triggers, the WHEN condition can refer to columns of the old and/or new row values by writing OLD.column_name or NEW.column_name respectively. Of course, INSERT triggers cannot refer to OLD and DELETE triggers cannot refer to NEW.

Currently, WHEN expressions cannot contain subqueries.

function_name

A user-supplied function that is declared as taking no arguments and returning type trigger, which is executed when the trigger fires.

arguments

An optional comma-separated list of arguments to be provided to the function when the trigger is executed. The arguments are literal string constants. Simple names and numeric constants can be written here, too, but they will all be converted to strings. Please check the description of the implementation language of the trigger function to find out how these arguments can be accessed within the function; it might be different from normal function arguments.

Notes

To create a trigger on a table, the user must have the TRIGGER privilege on the table. The user must also have EXECUTE privilege on the trigger function.

Use DROP TRIGGER to remove a trigger.

A column-specific trigger (FOR UPDATE OF column_name) will fire when any of its columns are listed as targets in the UPDATE command's SET list. It is possible for a column's value to change even when the trigger is not fired, because changes made to the row's contents by BEFORE UPDATE triggers are not considered. Conversely, a command such as UPDATE ... SET x = x ... will fire a trigger on column x, even though the column's value did not change.

In a BEFORE trigger, the WHEN condition is evaluated just before the function is or would be executed, so using WHEN is not materially different from testing the same condition at the beginning of the trigger function. Note in particular that the NEW row seen by the condition is the current value, as possibly modified by earlier triggers. Also, a BEFORE trigger's WHEN condition is not allowed to examine the system columns of the NEW row (such as oid), because those won't have been set yet.

In an AFTER trigger, the WHEN condition is evaluated just after the row update occurs, and it determines whether an event is queued to fire the trigger at the end of statement. So when an AFTER trigger's WHEN condition does not return true, it is not necessary to queue an event nor to re-fetch the row at end of statement. This can result in significant speedups in statements that modify many rows, if the trigger only needs to be fired for a few of the rows.

In PostgreSQL versions before 7.3, it was necessary to declare trigger functions as returning the placeholder type opaque, rather than trigger. To support loading of old dump files, CREATE TRIGGER will accept a function declared as returning opaque, but it will issue a notice and change the function's declared return type to trigger.

Examples

Execute the function check_account_update whenever a row of the table accounts is about to be updated:

CREATE TRIGGER check_update
    BEFORE UPDATE ON accounts
    FOR EACH ROW
    EXECUTE PROCEDURE check_account_update();

The same, but only execute the function if column balance is specified as a target in the UPDATE command:

CREATE TRIGGER check_update
    BEFORE UPDATE OF balance ON accounts
    FOR EACH ROW
    EXECUTE PROCEDURE check_account_update();

This form only executes the function if column balance has in fact changed value:

CREATE TRIGGER check_update
    BEFORE UPDATE ON accounts
    FOR EACH ROW
    WHEN (OLD.balance IS DISTINCT FROM NEW.balance)
    EXECUTE PROCEDURE check_account_update();

Call a function to log updates of accounts, but only if something changed:

CREATE TRIGGER log_update
    AFTER UPDATE ON accounts
    FOR EACH ROW
    WHEN (OLD.* IS DISTINCT FROM NEW.*)
    EXECUTE PROCEDURE log_account_update();

Section 36.4 contains a complete example of a trigger function written in C.

Compatibility

The CREATE TRIGGER statement in PostgreSQL implements a subset of the SQL standard. The following functionality is currently missing:

  • SQL allows you to define aliases for the "old" and "new" rows or tables for use in the definition of the triggered action (e.g., CREATE TRIGGER ... ON tablename REFERENCING OLD ROW AS somename NEW ROW AS othername ...). Since PostgreSQL allows trigger procedures to be written in any number of user-defined languages, access to the data is handled in a language-specific way.

  • PostgreSQL only allows the execution of a user-defined function for the triggered action. The standard allows the execution of a number of other SQL commands, such as CREATE TABLE, as the triggered action. This limitation is not hard to work around by creating a user-defined function that executes the desired commands.

SQL specifies that multiple triggers should be fired in time-of-creation order. PostgreSQL uses name order, which was judged to be more convenient.

SQL specifies that BEFORE DELETE triggers on cascaded deletes fire after the cascaded DELETE completes. The PostgreSQL behavior is for BEFORE DELETE to always fire before the delete action, even a cascading one. This is considered more consistent. There is also unpredictable behavior when BEFORE triggers modify rows or prevent updates during an update that is caused by a referential action. This can lead to constraint violations or stored data that does not honor the referential constraint.

The ability to specify multiple actions for a single trigger using OR is a PostgreSQL extension of the SQL standard.

The ability to fire triggers for TRUNCATE is a PostgreSQL extension of the SQL standard.

红蓝是什么意思 痛风是什么感觉 he是什么气体 什么地方能出生入死 丁亥日五行属什么
女人梦见大蟒蛇是什么征兆 雅典娜是什么神 七字五行属什么 感官世界讲的什么 肾炎有什么症状
硫酸亚铁适合浇什么花 什么是腰间盘突出 什么富什么车 怀孕两个月有什么症状 葡萄套袋前打什么药
天热出汗多是什么原因 柚子是什么季节 乳房胀痛挂什么科 熬夜为什么会胖 什么菜好吃
燕窝是什么做的hcv8jop0ns9r.cn 小腹痛什么原因hcv8jop6ns3r.cn 826是什么意思hcv7jop9ns1r.cn mmf是什么药hcv9jop0ns3r.cn 国家穷为什么不多印钱hcv8jop2ns5r.cn
变质是什么意思hcv9jop4ns0r.cn 海贼王什么时候出的hcv8jop8ns4r.cn bp是什么意思医学上面xjhesheng.com 折耳根是什么东西hcv7jop6ns9r.cn barbour是什么牌子luyiluode.com
撕脱性骨折是什么意思imcecn.com 皮肤干燥缺什么维生素hcv7jop7ns0r.cn 胃泌素瘤是什么意思hcv9jop5ns7r.cn 榨精是什么意思hcv8jop5ns5r.cn 女性潮热是什么症状hcv7jop5ns3r.cn
世五行属什么hcv9jop4ns2r.cn 不敢造次是什么意思hcv9jop2ns4r.cn 家里来猫是什么征兆hcv8jop6ns4r.cn 211是什么hcv9jop3ns2r.cn qc是什么hcv8jop5ns0r.cn
百度