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'
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'