DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006

    Create sequence script


    I've to remove the existing sequences in a schema & then i've to recreate
    those sequences with START WITH to old sequences current value.

    I've written a script as follows,to recreate current sequences after droppping them,

    select 'create sequence ' || sequence_name || ' start with ' ||
    ' increment by ' || INCREMENT_BY || ' minvalue ' || MIN_VALUE ||
    ' maxvalue ' || MAX_VALUE || ' CACHE ' || CACHE_SIZE || ' ' || case when cycle_flag='Y' then ' CYCLE ' end
    from user_sequences;

    Now the problem in this script is,I'm not able to set START WITH current values of the sequence,

    I tried with LAST_NUMBER,but it doesn't work for sequence which set with CACHE option.

    So,correct my script & guide me to get a script,that gives what i needed.


  2. #2
    Join Date
    Nov 2002
    Geneva Switzerland
    Obviously this has to be done when no one else is using your application.

    I think all you can do is take NEXTVAL from the sequence.
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.