Oracle get column/comment definitions for a table

Posted Ayumie

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle get column/comment definitions for a table相关的知识,希望对你有一定的参考价值。

select a.table_name,c.comments,a.column_name,b.comments,
       decode(a.data_type,‘VARCHAR2‘,a.data_type||‘(‘||a.data_length||‘)‘,‘CHAR‘,a.data_type||‘(‘||a.data_length||‘)‘,‘NUMBER‘,decode(a.data_precision,‘‘,a.data_type,a.data_type||‘(‘||a.data_precision||‘,‘||a.data_scale||‘)‘),a.data_type),
      ‘AS ‘||a.column_name||‘,‘,
      decode(b.comments,‘‘,‘‘,‘--‘||b.comments),
      decode(b.comments,‘‘,‘‘,a.column_name||‘ AS ‘||B.COMMENTS||‘,‘)
from dba_tab_cols a,dba_col_comments b,dba_tab_comments c
where a.table_name=‘TEST1114‘
and a.owner = ‘DB2‘
and a.owner = b.owner
and b.owner = c.owner
and a.table_name = b.table_name
and a.column_name = b.column_name
and a.table_name = c.table_name
order by a.column_id; 

  


select a.table_name,c.comments,a.column_name,b.comments,       decode(a.data_type,‘VARCHAR2‘,a.data_type||‘(‘||a.data_length||‘)‘,‘CHAR‘,a.data_type||‘(‘||a.data_length||‘)‘,‘NUMBER‘,decode(a.data_precision,‘‘,a.data_type,a.data_type||‘(‘||a.data_precision||‘,‘||a.data_scale||‘)‘),a.data_type),      ‘AS ‘||a.column_name||‘,‘,      decode(b.comments,‘‘,‘‘,‘--‘||b.comments),      decode(b.comments,‘‘,‘‘,a.column_name||‘ AS ‘||B.COMMENTS||‘,‘)from dba_tab_cols a,dba_col_comments b,dba_tab_comments cwhere a.table_name=‘DML_SD_BANK_GL‘and a.owner = ‘UUPSDB2‘and a.owner = b.ownerand b.owner = c.ownerand a.table_name = b.table_nameand a.column_name = b.column_nameand a.table_name = c.table_nameorder by a.column_id; 

以上是关于Oracle get column/comment definitions for a table的主要内容,如果未能解决你的问题,请参考以下文章

mysql 查询表结构

mysql 查询表结构

hive学习

如何在 oracle 中使用 get_ddl 从创建表脚本中忽略创建分段脚本?

Oracle利用dbms_metadata.get_ddl查看DDL语句

没有使用GET_FILE_NAME Oracle Forms打开对话框