[英]SQL for Oracle to check if a constraint exists
In SQL Server I can use the SQL below to check if a constraint exists and if it's a primary key, trigger, etc. 在SQL Server中,我可以使用下面的SQL来检查是否存在约束,以及它是否为主键,触发器等。
SELECT *
FROM dbo.sysobjects
WHERE id = OBJECT_ID(N'[SCHEMA].[TABLENAME]')
AND OBJECTPROPERTY(id, N'IsPrimaryKey') = 1
What would be the Oracle equivalent because my query uses SQL Server specific tables to find the answer. 什么是Oracle等价物,因为我的查询使用SQL Server特定的表来查找答案。
SELECT * FROM USER_CONSTRAINTS WHERE CONSTRAINT_NAME = 'CONSTR_NAME';
THE CONSTRAINT_TYPE
will tell you what type of contraint it is CONSTRAINT_TYPE
会告诉你它是什么类型的CONSTRAINT_TYPE
To find out if an object is a trigger, you can query USER_OBJECTS
. 要确定对象是否为触发器,可以查询
USER_OBJECTS
。 OBJECT_TYPE
will tell you if the object's a trigger, view, procedure et al. OBJECT_TYPE
将告诉您对象是否为触发器,视图,过程等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.