2011-06-08 46 views

回答

2

對於MySQL,Postgres的,或SQL Server,你可以使用INFORMATION_SCHEMA.TRIGGERS

SELECT * FROM INFORMATION_SCHEMA.TRIGGERS 
WHERE EVENT_OBJECT_SCHEMA = 'dbo' 
AND (EVENT_OBJECT_TABLE = 'Table1' OR LCASE(ACTION_STATEMENT) LIKE '%table1%') 
AND LCASE(ACTION_STATEMENT) LIKE '%foocolumn%'; 

Oracle不支持ANSI INFORMATION_SCHEMA,所以你可以改用:

SELECT * FROM DBA_TRIGGERS 
WHERE (TABLE_NAME = 'Table1' OR LCASE(TRIGGER_BODY) LIKE '%table1%') 
AND LCASE(TRIGGER_BODY) LIKE '%foocolumn%'; 

以上查詢查找爲Table1定義的觸發器,並影響FooColumn或爲另一個表格定義的觸發器e但影響Table1.FooColumn

請注意,如果DBMS支持可調用存儲過程(如Oracle)的觸發器,則必須手動檢查由觸發器調用的所有存儲過程。

相關問題