导出oracle序列

set serveroutput on;
spool c:/sequence_code.txt;
 
declare
  v_sequence varchar2(4000);
  v_nextval number(38,0);
begin
  for i in (select sequence_name from user_sequences) loop
   select dbms_metadata.get_ddl(‘SEQUENCE‘,i.sequence_name,user) into v_sequence from dual;
   execute immediate ‘select ‘||i.sequence_name||‘.‘||‘nextval from dual‘ into v_nextval;
   v_sequence := substr(v_sequence,1,instr(v_sequence,‘START WITH‘,1,1)+length(‘START WITH‘))||‘ ‘||to_char(v_nextval)||‘ ‘||
                 substr(v_sequence,instr(v_sequence,‘CACHE‘))||‘;‘;
   dbms_output.put_line(v_sequence);
  end loop;
end;
/
spool off;