Oracle查询字段的长度类型精度注释等信息

Posted 奔跑的金鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle查询字段的长度类型精度注释等信息相关的知识,希望对你有一定的参考价值。

 

查询数据字典中字段的相关信息

SELECT
T .column_name AS column_name, --列名
T .column_type AS column_type, ---字段类型
T .data_length AS data_length, --字段长度
T .data_scale AS data_scale, --字段精度
T .column_comment AS column_comment, --字段注释
case when substr(b.constraint_type,1,1)=P then N else null end as Is_PrimaryKey, --是否主键
DECODE(T.nullable,N,T.nullable,NULL) nullable –是否为空
FROM
(
SELECT
UB.tablespace_name AS database_name,
UTC.table_name AS table_name,
UTC.column_name AS column_name,
UTC.data_length AS data_length,
UTC.data_type AS column_type,
utc.data_scale AS data_scale,
ucc.comments AS column_comment,
utc.column_id,
utc.nullable
FROM
user_tables ub
LEFT JOIN user_tab_columns utc ON ub.table_name = UTC.table_name
LEFT JOIN user_col_comments ucc ON utc.column_name = ucc.column_name
AND utc.table_name = ucc.table_name
) T
LEFT JOIN (
SELECT
UCC.table_name AS table_name,
ucc.column_name AS column_name,
wm_concat (UC.constraint_type) AS constraint_type
FROM
user_cons_columns ucc
LEFT JOIN user_constraints uc ON UCC.constraint_name = UC.constraint_name
GROUP BY
UCC.table_name,
ucc.column_name
) b ON T .table_name = b.TABLE_NAME
AND T .column_name = b.column_name
where T.table_name=T0_CFG 
order by T.column_id

以上是关于Oracle查询字段的长度类型精度注释等信息的主要内容,如果未能解决你的问题,请参考以下文章

Oracle用sql查询某张表的字段信息(字段类型长度等)

Oracle 查询表字段 注释 以及表的注释

Oracle 查询表字段 注释 以及表的注释

关于oracle中number类型的长度和精度的一点整理.mark

如何使用sql语句,查询oracle的表注释等信息?

如何使用sql语句,查询oracle的表注释等信息?