DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Updating out of sync sequences

  1. #1
    Join Date
    May 2003
    Posts
    49

    Updating out of sync sequences ***Resolved***

    I have a live server which replicates data to a back up, occassionally I have to take the live server down and make the back up the live. When I do this my sequences are out of sync. Currently I have to manually update them.

    As follows -

    Code:
    SELECT max(myPk) FROM myTbl
    make a note of the val = X
    
    DROP SEQUENCE myPK;
    CREATE SEQUENCE myPK INCREMENT BY 1 START WITH X MINVALUE 1 NOCYCLE CACHE 20 NOORDER;
    commit;
    I would like to write a pl/sql procedure to do this on the fly, is it possible and has anyone done this already?

    I realise that one way round this problem would be to have a trigger on each table that increments and assigns the pk val on insert. It means altering my app. which will tak some time but will do it if it's the only way. Is this a good approach?

    Any help and or guidance will be gratefully received

    Cheers Al
    Last edited by Running Bear; 10-16-2003 at 03:09 AM.

  2. #2
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Before you shutdown the db, put the sequence in nocache option.
    The command is:
    alter sequence sequencename nocache.

    This will gurantee the out of sync in sequences next time you start up the db.

    Tamil

  3. #3
    Join Date
    May 2003
    Posts
    49
    Tamil,

    Thanks for that, I'll give it a go.

    Regards Al

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