Этот скрипт мне помог:
create or replace function mymetadata return sys.ku$_ddls is
md_handle number;
tr_handle number;
dl_handle number;
result_array sys.ku$_ddls;
begin
md_handle := dbms_metadata.open('TABLE');
tr_handle := dbms_metadata.add_transform(md_handle, 'MODIFY');
dbms_metadata.set_remap_param(tr_handle, 'REMAP_SCHEMA', 'MLIS_DEV', null);
dl_handle := dbms_metadata.add_transform(md_handle, 'DDL');
dbms_metadata.set_transform_param(dl_handle, 'SEGMENT_ATTRIBUTES', false);
dbms_metadata.set_transform_param(dl_handle, 'STORAGE', false);
dbms_metadata.set_transform_param(dl_handle, 'TABLESPACE', false);
dbms_metadata.set_transform_param(dl_handle, 'REF_CONSTRAINTS', false);
dbms_metadata.set_transform_param(dl_handle, 'SQLTERMINATOR', true);
dbms_metadata.set_transform_param(dl_handle, 'CONSTRAINTS_AS_ALTER', true);
LOOP
result_array := dbms_metadata.fetch_ddl(md_handle);
EXIT WHEN result_array IS NULL;
FOR i IN result_array.FIRST..result_array.LAST LOOP
dbms_output.put_line(result_array(i).ddltext);
END LOOP;
END LOOP;
dbms_metadata.close(md_handle);
md_handle := dbms_metadata.open('REF_CONSTRAINT');
tr_handle := dbms_metadata.add_transform(md_handle, 'MODIFY');
dbms_metadata.set_remap_param(tr_handle, 'REMAP_SCHEMA', 'MLIS_DEV', null);
dl_handle := dbms_metadata.add_transform(md_handle, 'DDL');
dbms_metadata.set_transform_param(dl_handle, 'SQLTERMINATOR', true);
LOOP
result_array := dbms_metadata.fetch_ddl(md_handle);
EXIT WHEN result_array IS NULL;
FOR i IN result_array.FIRST..result_array.LAST LOOP
dbms_output.put_line(result_array(i).ddltext);
END LOOP;
END LOOP;
dbms_metadata.close(md_handle);
return result_array;
end;
/
select ddltext from table(mymetadata);