查詢表中所有列名及備註

2021-04-25 09:21:56 字數 2064 閱讀 1866

select   *

from   ::fn_listextendedproperty (null, 'user', 'dbo', 'table', 'cp_jckqk', 'column', default)

select b.name as tblname, c.name as colname, a.[value] as description

from sysproperties a

inner join sysobjects b on a.id = b.id

inner join syscolumns c on a.id = c.id and a.smallid = c.colid

where (a.name = 'ms_description') and b.name = 'cp_jckqk'

//帶欄位型別

select a.name as 欄位名, b.name as 型別,g.[value]

from syscolumns a inner join

systypes b on a.xusertype = b.xusertype inner join

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

left join

sysproperties g on a.id = g.id and a.colid = g.smallid

where (d.name = 'cp_jckqk')

order by a.id

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

表說明 = case when a.colorder = 1 then isnull(f.value, '') else '' end,

字段序號 = a.colorder, 欄位名 = a.name,

標識 = case when columnproperty(a.id, a.name, 'isidentity')

= 1 then '√' else '' end, 主鍵 = case when exists

(select 1

from sysobjects

where xtype = 'pk' and parent_obj = a.id 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,

型別 = b.name, 占用位元組數 = a.length, 長度 = columnproperty(a.id, a.name,

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

允許空 = case when a.isnullable = 1 then '√' else '' end, 預設值 = isnull(e.text,

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

from syscolumns a left join

systypes b on a.xusertype = 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.smallid left join

sysproperties f on d .id = f.id and f.smallid = 0

order by a.id, a.colorder

查詢資料庫中所有列名

如何從整個資料庫所有表中查詢出乙個列名?比如想要查詢乙個名為 name 的列名,但是忘記了這一列是在那乙個表中,需要從整個資料庫的所有表中進行查詢。oracle 資料庫 select from user col comments s where s.column name like name mys...

查詢表中所有字段

查詢某個表的欄位名 select column name from user tab columns where table name tablename 多行合併為一行,便於操作,可以用 wm concat select wm concat column name from user tab co...

查詢資料庫中所有表名,查詢表中所有欄位名

mysql 1.查詢資料庫中所有表名稱 select table name from information schema.tables where table schema 資料庫名稱 包含檢視 select table name from information schema.tables wh...