匯出表結構

2021-04-02 01:48:03 字數 1080 閱讀 8914

select

表名 = case when a.colorder=1 then d.name else '' end,

字段序號 = a.colorder,

欄位名 = a.name,

字段說明 = isnull(g.[value],''),

型別 = b.name,

占用位元組數 = a.length,

長度 = columnproperty(a.id,a.name,'precision'),

小數字數 = isnull(columnproperty(a.id,a.name,'scale'),0),

標識 = case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end,

主鍵 = case when exists(

select 1 from sysobjects where xtype='pk' and name in (

select name from sysindexes where indid in (select indid from sysindexkeys where id = a.id and colid=a.colid)

)) then '√' else '' end,

允許空 = case when a.isnullable=1 then '√'else '' end,

預設值 = isnull(e.text,'')

from syscolumns a

left join systypes b on a.xtype=b.xusertype

inner join sysobjects d on a.id=d.id and d.xtype='u' and d.name<>'dtproperties'

left join syscomments e on a.cdefault=e.id

left join sysproperties g on a.id=g.id and a.colid=g.**allid

where d.name like '表名%'

order by a.id,a.colorder

匯出表結構

資料庫遷移時,匯出表結構,用設計工具匯入 1 select 欄位名 a.name,名稱 a.name,型別 case when b.name int then 整數 when b.name ntext then 文字 when b.name date then 日期 when b.name smal...

匯出表結構

select 欄位名 c.name,字段說明 isnull pfd.value n 型別 t.name,長度 c.max length,預設值 isnull d.definition,n 允許空 case when c.is nullable 1 then n else n end,isnull i...

Oracle 匯出表結構

分析oracle下匯出某使用者所有表的方法 可能很多使用oracle的客戶都會遇到想把某使用者所有表匯出的情況,本文就提供這樣乙個方法幫你輕鬆解決這個問題。首先在sqlplus下以該使用者登入到oracle資料庫,然後將以下內容貼上到sqlplus中 set feedback off set pag...