Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 3 of 3 total |
Resetting Identity field |
Wed, Oct 21 2009 1:53 PM | Permanent Link |
Michael Fullerton | How do you reset the identity field to a different value? I tried:
ALTER TABLE "MyTable" ALTER COLUMN ID AS INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) and ALTER TABLE "MyTable" ALTER COLUMN ID AS INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) and neither worked as any new record started with 1 more than the previous highest value. |
Wed, Oct 21 2009 2:07 PM | Permanent Link |
Uli Becker | Michael,
> How do you reset the identity field to a different value? I tried: > ALTER TABLE "MyTable" ALTER COLUMN ID AS INTEGER GENERATED ALWAYS AS > IDENTITY (START WITH 1, INCREMENT BY 1) You have to use "RESTART WITH 1" in order to set back the seed. Regards Uli |
Wed, Oct 21 2009 5:24 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Michael,
As Uli indicated, you need to use the RESTART WITH clause to reset the *existing value*: ALTER TABLE "MyTable" ALTER COLUMN ID RESTART WITH 1 Just altering the original column definition will not do it, since that only specifies what the seed and increment values should be for a new, empty table. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Sunday, May 5, 2024 at 10:18 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |