관리 메뉴

Data Modeling Evangelist Kaien Kim's Blog

[SQLServer]특정테이블의 컬럼정보 가져오기 본문

DATA/SQLServer

[SQLServer]특정테이블의 컬럼정보 가져오기

2009. 1. 16. 17:08
-- 특정테이블의 컬럼정보가져오기
select *
FROM INFORMATION_SCHEMA.COLUMNS
where table_name = 'Customer'
order by table_name,ordinal_position

-- 특정테이블의 PK정보가져오기
select constraint_name from information_schema.table_constraints
where constraint_type='PRIMARY KEY'
   and table_name = 'Customer'

-- 특정테이블의 FK정보가져오기
select constraint_name from information_schema.table_constraints
where constraint_type='FOREIGN KEY'
   and table_name = 'Customer'