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='TEST1114'and a.owner = 'DB2'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;
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;