--以表AA11为例
select 'create table ' || a.table_name || '(' || chr(10) ||
(select TO_CHAR(wm_concat(b.column_name || ' ' || b.DATA_TYPE || '(' ||b.DATA_LENGTH || ') ' ||
decode(b.NULLABLE, 'N', ' not null ', '') ||
chr(10)))
from (select * from user_tab_columns order by COLUMN_ID) b
where b.table_name = a.table_name) || ');' || chr(10) ||
'comment on table ' || a.table_name || ' is ''' || comments||''';'||chr(10)||
(select replace(TO_CHAR(wm_concat('comment on column '||e.table_name||'.'||e.column_name||' is '''||e.comments||''';')),',',chr(10)) from (select c.TABLE_NAME,c.COLUMN_NAME,d.comments from user_tab_columns c,u