Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Resetting Identity field
Wed, Oct 21 2009 1:53 PMPermanent 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 PMPermanent 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 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email 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

Image