Sunday, October 21, 2007

Get schema of one table

select t2.name [TABLE_NAME]
, t1.name [COLUMN_NAME]
, t4.name [TYPE_NAME]
, t1.max_length
, t1.precision
, t1.scale
, t1.is_nullable
, t1.is_identity
, t3.seed_value
, t3.increment_value
from sys.columns t1
inner join sys.tables t2 on t1.[object_id] = t2.[object_id]
left join sys.identity_columns t3 on t1.column_id = t3.column_id and t2.[object_id] = t3.[object_id]
inner join sys.types t4 on t1.[user_type_id] = t4.[user_type_id]
where t2.name = 'table_name'

No comments:

Post a Comment

Oracle Query