oracle 如何匯出資料字典

2021-06-20 13:23:29 字數 3591 閱讀 3277

-- 查詢某錶的資料字典

select  a.table_name as "表名",a.column_name as "欄位名",

decode(a.char_length,0,decode(a.data_scale,null,a.data_type,a.data_type||'('||a.data_precision||','||a.data_scale||')'),

a.data_type||'('||a.char_length||')') as "字段型別1",a.data_type as "字段型別",a.data_precision as "有效位",a.data_scale as "精度值",

a.char_length as "字段長度",a.nullable as "能否為空"

from sys.user_tab_columns a where a.table_name = 'tam_address'

--  具有dba許可權使用者匯出資料字典

select  a.table_name as "表名",a.column_name as "欄位名",

decode(a.char_length,0,decode(a.data_scale,null,a.data_type,a.data_type||'('||a.data_precision||','||a.data_scale||')'),

a.data_type||'('||a.char_length||')') as "字段型別",a.data_default as "預設值",

a.nullable as "能否為空",b.comments as "備註"

from sys.all_tab_columns a,sys.dba_col_comments b

where a.owner=b.owner and a.table_name=b.table_name  and a.column_name=b.column_name and a.owner='guoqiang'  and

a.table_name in (

'tb_subject', 'tb_subject_balance', 'tb_voucher', 'tb_voucher_details', 

'tb_customer', 'tb_voucher_classify_mode', 'tb_voucher_type', 'tb_asset', 

'tb_asset_catalog', 'tb_m_dm_assets_liabi_rpt', 'tb_m_dm_profit_rpt', 

'tb_m_dm_revenue_rpt', 'tb_m_dm_cost_rpt'

)order by a.table_name

--一般使用者匯出該使用者下的資料字典

select  a.table_name as "表名",a.column_name as "欄位名",

decode(a.char_length,0,decode(a.data_scale,null,a.data_type,a.data_type||'('||a.data_precision||','||a.data_scale||')'),

a.data_type||'('||a.char_length||')') as "字段型別",a.data_default as "預設值",

a.nullable as "能否為空",b.comments as "備註"

from sys.user_tab_columns a,sys.user_col_comments b

where a.table_name=b.table_name  and a.column_name=b.column_name and

a.table_name in (

'tb_subject', 'tb_subject_balance', 'tb_voucher', 'tb_voucher_details', 

'tb_customer', 'tb_voucher_classify_mode', 'tb_voucher_type', 'tb_asset', 

'tb_asset_catalog', 'tb_m_dm_assets_liabi_rpt', 'tb_m_dm_profit_rpt', 

'tb_m_dm_revenue_rpt', 'tb_m_dm_cost_rpt'

)order by a.table_name

---4查詢該使用者下面所有表對應的資料字典

select col.table_name,

--col.column_id as colorder,

tt.comments,

col.column_name as columnname,

case

when pkcol.column_position > 0 then

'√'else

''end as ispk,

col.data_type as typename,

--decode(col.data_type, 'number', col.data_precision, col.data_length) as length,

col.data_length    占用位元組數,

col.data_precision as preci,

col.data_scale     as scale,

case

when col.nullable = 'y' then

'√'else

''end as cisnull,

-- '' as isidentity,

col.data_default as defaultval,

ccom.comments    as detext /*,

col.num_distinct as num_distinct*/

from user_tab_columns col,

user_col_comments ccom,

(select aa.table_name,

aa.index_name,

aa.column_name,

aa.column_position

from user_ind_columns aa, user_constraints bb

where bb.constraint_type = 'p'

and aa.table_name = bb.table_name

and aa.index_name = bb.constraint_name

/*and aa.table_name in ('aa')*/

) pkcol,

user_tab_comments tt

where col.table_name = ccom.table_name

and col.column_name = ccom.column_name

and col.table_name = tt.table_name(+)

-- and col.table_name = 'aa'

and col.column_name = pkcol.column_name(+)

and col.table_name = pkcol.table_name(+)

order by col.table_name,col.column_id

oracle 如何匯出資料字典

查詢某錶的資料字典 select a.table name as 表名 a.column name as 欄位名 decode a.char length,0,decode a.data scale,null,a.data type,a.data type a.data precision a.da...

Oracle使用之 匯出資料字典

select from user tab comments where table name like web ply base select from dba tab comments where table name like web ply base select wm concat colu...

mysql 匯出資料字典

select table catalog,table schema as 資料庫名,table name as 表名,column name as 欄位名,ordinal position as 字段位置,column default as 字段預設值,is nullable 是否允許空值,data...