寻找 sql 命令来查找活动触发器及其关联表

问题描述 投票:0回答:1

我正在尝试在 Sybase 中查找活动触发器及其关联表。书面询问是什么?

我发现以下 SQL 命令很有用

select *  from sysobjects  where type = "TR"  where deltrig =1 or instrig = 1 or updtrig =1

但是,我不知道如何将触发器名称与表名称关联起来。

sql sybase sap-ase
1个回答
0
投票

我在一年后回到这个问题时找到了答案

SELECT 
    triggers.name AS trigger_name,
    tables.name AS table_name
FROM 
    sysobjects AS triggers
JOIN 
    sysobjects AS tables 
    ON triggers.id = tables.deltrig 
       OR triggers.id = tables.instrig 
       OR triggers.id = tables.updtrig
WHERE 
    triggers.type = "TR"  -- Only triggers
    AND tables.type = "U" -- Only user tables
ORDER BY 
    tables.name, triggers.name;
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.