Using DBMS_METADATA to duplicate sequences between schemas

The following anonymous plsql block will allow you to duplicate all sequences insode one schema to another schema. The example assumes you are logged as as pumpy with approriate rights and you are duplicating into SYSTEM.


declare
v_sql varchar2(4000);
v_newsql varchar2(4000);
cursor c is select sequence_name from user_sequences;
begin
for rec in c loop
v_sql := dbms_metadata.get_ddl('SEQUENCE',rec.sequence_name);
v_newsql := replace(v_sql,'PUMPY','SYSTEM');
execute immediate v_newsql;
end loop;
end;

0 comments:

Post a Comment