Rene Bosch <> schrieb am Friday, February 11, 2011 3:48 PM:

> Maybe a stupid question, but I'm not that much of an expert on
> DBMS's ....
> 
> I have a table with an field that is an IDENTITY field.  It is loaded
> with records form a daily incoming file.  The sequence number of the
> identity field gives an indication of the order in which records come
> in.
> Sometimes I need to start loading this table from scratch.  I do this
> by TRUNCATE-ing it.  But when I again insert entries the IDENTITY
> field continues numbering where it left off before the TRUNCATE.  For
> my purpose I need to have it start with 1 again.
> 
> How can you do that?

ALTER SEQUENCE sequenceName [RESTART WITH long] [INCREMENT BY long]
        
Changes the next value and the increment of a sequence. This command does not 
commit the current transaction; however the new value is used by other 
transactions immediately, and rolling back this command has no effect.

Example:

ALTER SEQUENCE SEQ_ID RESTART WITH 1000
Changes the next value and the increment of a sequence. This command does not 
commit the current transaction; however the new value is used by other 
transactions immediately, and rolling back this command has no effect.

Wolfgang

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to