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`;