tft每日頭條

 > 科技

 > mysql觸發器實戰教程

mysql觸發器實戰教程

科技 更新时间:2024-09-04 02:17:40
一、概述

下面分享幾個查詢mysql存儲過程和觸發器的語句

二、相關語句2.1 觸發器
  • 列出 MySQL 數據庫中的觸發器

select trigger_schema as trigger_database, trigger_name, concat(event_object_schema, '.', event_object_table) as trigger_table, action_order, action_timing, event_manipulation as trigger_event, action_statement as 'definition' from information_schema.triggers where trigger_schema not in ('sys','mysql') -- and trigger_schema = 'database_name' -- put your database name here order by trigger_schema, trigger_name;

說明:

  • trigger_database - 觸發器所在的數據庫的名稱
  • trigger_name - 觸發器的名稱
  • action_order - 觸發器操作在同一張表上具有相同 trigger_event 和 action_timing 的觸發器列表中的序号位置
  • action_timing - 觸發激活時間:before、after
  • trigger_event - 具體的 SQL 操作:insert、update、delete
  • trigger_table - 帶有數據庫(模式)名稱的觸發器表的名稱
  • 定義- 觸發器的 SQL定義

mysql觸發器實戰教程(DBA技術分享十-)1

2.2 存儲過程

select routine_schema as database_name, routine_name, routine_type as type, data_type as return_type, routine_definition as definition from information_schema.routines where routine_schema not in ('sys', 'information_schema', 'mysql', 'performance_schema') -- and r.routine_schema = 'database_name' -- put your database name here order by routine_schema, routine_name;

說明:

  • database_name - 數據庫的名稱(模式)
  • routine_name - 函數/過程的名稱
  • 類型-程序功能
  • return_type - 對于存儲函數,返回值數據類型,否則此值為空
  • 定義- 函數/過程執行的 SQL 語句的文本

mysql觸發器實戰教程(DBA技術分享十-)2

小結

後面會分享更多Linux和DBA方面内容,感興趣的朋友可以關注下!

mysql觸發器實戰教程(DBA技術分享十-)3

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved