在sql server中查詢字段資訊的語句:
select a.name as tablename,
b.name as columnname,
case when h.id is not null then'pk' else 'no' end as primarykey,
type_name(b.xusertype) + case when b.colstat & 1 = 1 then '[id(' + convert(varchar,ident_seed(a.name)) + ',' + convert(varchar,ident_incr(a.name)) + ')]' else '' end as type,
b.length,
case b.isnullable when 0 then 'n' else 'y' end as [colisnull],
isnull(e.text,'') as [defaultvalue],
isnull(c.value,'') as descript
from syscolumns b
left join sysobjects a on b.id=object_id(a.name)
left join (select g.id,g.colid from sysindexes f,sysindexkeys g where f.id = g.id and f.indid = g.indid and f.indid > 0 and f.indid < 255 and (f.status & 2048)<>0) h on b.id = h.id and b.colid = h.colid
left join syscomments e on b.cdefault = e.id
left join sysproperties c on b.id = c.id and b.colid = c.**allid
where a.xtype='u' and a.status > 0
order by a.name,b.colorder
根據表名獲取表字段資訊
實際應用中不免需要調取資料庫表字段的相關資訊,特此將 貼出,以作備用,調取的資訊 欄位名 字段型別 字段長度 是否主鍵 說明 建立sqlparameter public class cp public sqldbtype coltype public int collength public boo...
查詢oracle表字段資訊
查詢oracle表字段資訊 表字段的資訊咱們可以稱之為元資料,今天有人問怎麼把表字段的資訊匯出來,說實話我還不會用plsql develper把錶的結構匯出來,像下圖所示 在寫資料庫設計說明書的時候,想要把這個 拷貝出來,這樣就事半功倍,不用乙個個複製貼上了,而且減少出錯的概率,但遺憾的是,這個介面...
SQL 查詢表結構資訊 表字段注釋
查詢表結構資訊 select case when a.colorder 1 then i.name d.name else end 表名,a.name 欄位名,isnull g.value as 說明 a.colorder 字段序號,case when select count 1 from sys...