查詢資料表的字段資訊

2021-09-29 15:05:12 字數 2240 閱讀 9008

--col_name欄位名,col_type欄位型別,col_comment欄位含義;

--tablename表名,username使用者名稱;

select

c.column_name col_name,

c.data_type col_type,

(select comments from all_col_comments cm where cm.table_name = c.table_name and cm.owner = c.owner and cm.column_name = c.column_name and rownum =

1) col_comment

from

all_tab_columns c

where

c.table_name =

'tablename'

and c.owner =

'username'

--col_name欄位名,col_type欄位型別,col_comment欄位含義;

--tablename表名,username使用者名稱;

select

column_name col_name,

data_type col_type,

column_comment col_comment

from

information_schema.

columns

where

table_name =

'tablename'

and table_schema =

'username'

--col_name欄位名,col_type欄位型別,col_comment欄位含義;

--tablename表名,username使用者模式名;

select

cols.name col_name,

cols.

type col_type,

cols.resvd5 col_comment

from

sysdba.systables t

inner

join

sysdba.syscolumns cols

on cols.id=t.id

inner

join

sysdba.sysschemas sch

on sch.schid=t.schid

where

t.name=

'tablename'

and sch.name =

'username'

--col_name欄位名,col_type欄位型別,col_comment欄位含義,col_length字段長度;

--tablename表名,username使用者模式名;

select

cols.name col_name ,

cols.

type$ col_type ,

cc.comment$ col_comment,

cols.length$ col_length

from

sysobjects t

inner

join syscolumns cols

on cols.id=t.id

left

join syscolumncomments cc

on cc.tvname =t.name

and cols.name =cc.colname

and cc.schname=

'username'

left

join systablecomments tc

on tc.tvname =t.name

and tc.table_type=

'table'

and tc.schname =

'username'

where

t.name =

'tablename'

and t.schid=

(select id from sysobjects where

type$=

'sch'

and name=

'username'

)

mysql 檢視資料表結構,查詢資料表欄位名

describe命令 一 describe命令用於檢視特定表的詳細設計資訊,例如為了檢視guestbook表的設計資訊,可用 describe guestbook describe ol user userid 二 可通過 show comnus 來檢視資料庫中表的列名,有兩種使用方式 show c...

獲取資料庫某張資料表的字段資訊

adoc main.openschema sicolumns,vararrayof null,null,mytable emptyparam,adodataset1 while not adodataset1.eof do begin.end 其中adodataset1的屬性有 able catal...

查詢MySQL資料表的欄位名和表結構

查詢表的字段 查詢表的欄位名 select column name group concat a.column name separator as column name 加表別名並用逗號連線 from information schema.columns where table schema he...