Search code examples
oracle-databasehibernategrailssquirrel-sql

how do I update hibernate_sequence in Grails using oracle 11g database?


I imported some data into my schema and I have one sequence for all my tables. In my old app, the sequence was around 1000, but this new sequence is starting at 4, and thus I am getting conflicts when trying to enter a new row. Is there a way to update the sequence or is there a way to set the sequence to a certain number during db creation? I don't mind doing a create-drop and importing the data again. I basically just want to set the sequence to start at 1000. Thanks.


Solution

  • You should be able to increase the increment, access the sequence and then reset the increment, e.g.:

    alter sequence [sequence name]
    increment by [desired value minus current value];
    
    select [sequence name].nextval from dual;
    
    alter sequence [sequence name]
    increment by 1;
    

    I got this syntax from: http://www.techonthenet.com/oracle/sequences.php