Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 8 of 8 total |
Reset AutoInc Number |
Tue, Oct 30 2007 1:15 AM | Permanent Link |
Jianfei Xu | Hi, Tim
If I delete all records from the table and would like to start from 0 again for the identifier field. How to do that. BTW, How can I get the last id number for identifier field? Thanks Jianfei |
Tue, Oct 30 2007 5:47 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Jianfei,
<< If I delete all records from the table and would like to start from 0 again for the identifier field. How to do that. >> Just use an ALTER TABLE statement that does the following: ALTER TABLE MyTable DROP COLUMN IDColumn, ADD COLUMN IDColumn INTEGER GENERATED ALWAYS AS IDENTITY.... http://www.elevatesoft.com/edb1sql_alter_table.htm As of 1.06, you'll be able to use the ALTER COLUMN IDColumn AS syntax instead. << BTW, How can I get the last id number for identifier field? >> Just use a: SELECT MAX(IDColumn) FROM MyTable query. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Oct 31 2007 12:30 PM | Permanent Link |
"Jianfei Xu" | > ALTER TABLE MyTable
> DROP COLUMN IDColumn, > ADD COLUMN IDColumn INTEGER GENERATED ALWAYS AS IDENTITY.... Does not work. I guess that info must be stored somewhere. Jianfei |
Wed, Oct 31 2007 1:21 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Jianfei,
<< Does not work. I guess that info must be stored somewhere. >> What was the exact SQL statement that you used ? You need to make sure to set the seed value. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Oct 31 2007 1:26 PM | Permanent Link |
"Jianfei Xu" | SQLc := 'ALTER TABLE '+TN+ ' DROP COLUMN "xID",'+ ' ADD COLUMN "xID" INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 0, INCREMENT BY 1)'; Jianfei |
Wed, Oct 31 2007 1:30 PM | Permanent Link |
"Jianfei Xu" | > << BTW, How can I get the last id number for identifier field? >>
> > Just use a: > > SELECT MAX(IDColumn) FROM MyTable > > query. If some records get deleted, then, the MAX(IDColumn) will not be able tell the last ID number! Jianfei |
Thu, Nov 1 2007 5:12 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Jianfei,
<< If some records get deleted, then, the MAX(IDColumn) will not be able tell the last ID number! >> Perhaps you could tell me what you need the last number for, and then I can tell you how best to do what you want. -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Nov 1 2007 5:13 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Jianfei,
<< SQLc := 'ALTER TABLE '+TN+ ' DROP COLUMN "xID",'+ ' ADD COLUMN "xID" INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 0, INCREMENT BY 1)'; >> Okay, I'm going to need to make some modifications to accomodate this in 1.06 because currently the see value is not reset as expected. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |