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

DATABASE/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'
Trackbacks 0 : Comments 0

Write a comment