可以用utl_file输出到日志文件。例如 create or replace directory logfile_target as '/u01/oracle'; grant read,write on directory logfile_target to public;DECLARE l_file utl_file.file_type; BEGIN l_file := utl_file.fopen('LOGFILE_TARGET', 'sql.log', 'W'); for row in (select * from user_tables) loop utl_file.put_line(l_file, dbms_metadata.get_ddl('TABLE', row.table_name)); end loop; utl_file.fclose(l_file); END;
create or replace directory logfile_target as '/u01/oracle';
grant read,write on directory logfile_target to public;DECLARE
l_file utl_file.file_type;
BEGIN
l_file := utl_file.fopen('LOGFILE_TARGET', 'sql.log', 'W');
for row in (select * from user_tables)
loop
utl_file.put_line(l_file, dbms_metadata.get_ddl('TABLE', row.table_name));
end loop;
utl_file.fclose(l_file);
END;