심재운 블로그

반응형

Method 1: INFORMATION_SCHEMA

SELECT
DISTINCT
Constraint_Name AS [Constraint],
Table_Schema AS [Schema],
Table_Name AS [TableName]
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
GO

Method 2: sys.objects

SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint,
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(parent_object_id) AS TableName,
type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc IN ('FOREIGN_KEY_CONSTRAINT','PRIMARY_KEY_CONSTRAINT')
GO

PRIMARY KEY 와 FOREIGN KEY 를 전부 뽑아주는 쿼리 들이다.

METHOD 2 가 성능이 제일 좋고, 결과값도 많다.


반응형
이 장소를 Daum지도에서 확인해보세요.
서울특별시 관악구 신원동 | 신림1동날으는돈까스
도움말 Daum 지도

댓글

비밀글모드

  1. It’s really useful matter and interesting one. Great job done keep going like this information.
    2012.08.04 12:27