日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

mysql:triggers

發(fā)布時(shí)間:2023/12/3 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql:triggers 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

參考

http://www.mysqltutorial.org/mysql-triggers.aspx

mysql:triggers

被預(yù)先編寫并存儲(chǔ)在表中的程序, 該程序被特定的 events觸發(fā), 比如 對表的 DML 操作
By definition, a trigger or database trigger is a stored program executed automatically to respond to a specific event e.g., insert, update or delete occurred in a table.

被用于: 保護(hù)數(shù)據(jù)的完整性和一致性,
以及 自動(dòng) logging 和 審計(jì) 等

A SQL trigger is a set of SQL statements stored in the database catalog. A SQL trigger is executed or fired whenever an event associated with a table occurs e.g., insert, update or delete.

trigger vs stored procedure

A SQL trigger is a special type of stored procedure. It is special because it is not called directly like a stored procedure. The main difference between a trigger and a stored procedure is that a trigger is called automatically when a data modification event is made against a table whereas a stored procedure must be called explicitly.

advantages of Using triggers

  • 提供了一個(gè)檢查 數(shù)據(jù)完整性和一致性的方式

  • 可以在數(shù)據(jù)庫內(nèi)捕捉 業(yè)務(wù)邏輯的錯(cuò)誤

  • 支持 run scheduled task

  • 4, 支持對 數(shù)據(jù)變更的審查

    disadvantages of Using triggers

  • triggers僅能提供一種對數(shù)據(jù)審查的擴(kuò)展, 而不能替代所有的審查工作

  • triggers 執(zhí)行對 clients不可見

  • triggers 加大了mysql server 的負(fù)擔(dān)

  • triggers 實(shí)現(xiàn):

  • 定義和存儲(chǔ) triggers
    You must use a unique name for each trigger associated with a table
  • The tablename.TRG file maps the trigger to the corresponding table.
    the triggername.TRN file contains the trigger definition.

  • the limitations of triggers
  • MySQL triggers cannot:

    • Use SHOW, LOAD DATA, LOAD TABLE, BACKUP DATABASE, RESTORE, FLUSH and RETURNstatements.
    • Use statements that commit or rollback implicitly or explicitly such as COMMIT , ROLLBACK , START TRANSACTION , LOCK/UNLOCK TABLES , ALTER , CREATE , DROP , RENAME.
    • Use prepared statements such as PREPAREand EXECUTE.
    • Use dynamic SQL statements.

    create triggers

    定義 tables 用來存放 triggers 獲取的數(shù)據(jù);

    定義 tiggers, associated with a table;

    scheduled event

    類似于 定時(shí)器

    總結(jié)

    以上是生活随笔為你收集整理的mysql:triggers的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。