當前位置:首頁 » 數據倉庫 » 資料庫查看錶的觸發器
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

資料庫查看錶的觸發器

發布時間: 2022-10-05 03:20:25

A. 如何查詢資料庫中的所有觸發器

select name from sysobjects where xtype='TR' --所有觸發器
select name from sysobjects where xtype='P' --所有存儲過程
select name from sysobjects where xtype='V' --所有視圖
select name from sysobjects where xtype='U' --所有表

以上為sqlServer用法

Select object_name From user_objects Where object_type='TRIGGER'; --所有觸發器
Select object_name From user_objects Where object_type='PROCEDURE'; --所有存儲過程
Select object_name From user_objects Where object_type='VIEW'; --所有視圖
Select object_name From user_objects Where object_type='TABLE'; --所有表

以上為Oracle用法

以上,希望對你有所幫助!

B. 如何在資料庫中查詢出所有有觸發器的表

select name from sysobjects where xtype='TR' --所有觸發器名稱
select name from sysobjects where xtype='P' --所有存儲過程
select name from sysobjects where xtype='V' --所有視圖
select name from sysobjects where xtype='U' --所有表
全部禁用:Alter table t1 disable trigger all;
全部生效:Alter table t1 enable trigger all;
單個禁用:Alter table t1 disable trigger 觸發器名;
查出指定TR的內容:sp_helptext 't_test'
查出所有非系統資料庫並列出:
select * from sysdatabases where dbid>4
查出某表中所有欄位名與欄位類型:
select a.name as [column],b.name as type
from syscolumns a,systypes b
where a.id=object_id('employee') and a.xtype=b.xtype!

C. sql如何查看錶觸發器信息:就是我想要看這個表有幾個觸發器 還有觸發器的名字 用 語句實現!!

呵呵,看到你的這個問題了,回答一下,希望能給你增加印象。
由於sqlserver
沒有oracle中的行級觸發器的概念,觸發器如下:
create
trigger
[tc2]
on
[dbo].[teacher]
for
insert,update
as
if
(select
salary
from
inserted)<3000
update
teacher
set
salary=3000
and
tid=
(select
tid
from
inserted)
說明:當你插入數據的時候,這條數據是存放在【inserted】表中的,在這個表中把【teacher】表的主鍵得到(假如是【tid】)然後把這個主鍵信息加到where
條件上,這樣就能起到只更新插入的那一條數據的效果了,否則會出現更新了全表的問題。
---
以上,希望對你有所幫助。

D. 如何查詢資料庫中的所有觸發器名稱,及啟用還是禁用!

select name from sysobjects where xtype='P' --所有存儲過程 select name from sysobjects where xtype='V' --所有視圖 select name from sysobjects where xtype='U' --所有表 全部禁用:Alter table t1 disable trigger all; 全部生效:Alter table t1 enable trigger all; 單個禁用:Alter table t1 disable trigger 觸發器名; 查出指定TR的內容:sp_helptext 't_test' 查出所有名稱與內容: select b.name as 名稱,a.text as 內容,case xtype when 'p ' then '存儲過程 ' else '觸發器 ' end as 類型 from syscomments a,sysobjects b where object_id(b.name)=a.id and b.xtype in( 'P ', 'TR ') and b.status =0 order by 類型 查出所有非系統資料庫並列出: select * from sysdatabases where dbid4 查出某表中所有欄位名與欄位類型: select a.name as [column],b.name as type from syscolumns a,systypes b where a.id=object_id('employee') and a.xtype=b.xtype -------------------- 查出觸發器是啟用還是禁用。 select a.name as 觸發器名,b.name as 表名,

E. mysql如何查看錶中的所有約束和觸發器

可以從information_schema架構下的系統表查看

-- 查看約束
SELECT * FROM information_schema.`TABLE_CONSTRAINTS`;

-- 查看觸發器
SELECT * FROM information_schema.`TRIGGERS`;