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
If you didn't explicitly used a sequence, then I think what your are
looking for is:
ALTER TABLE TEST ALTER COLUMN ID RESTART WITH 10000;
See also http://h2database.com/html/grammar.html#alter_table_alter
I wonder if other databases reset the identity if you truncate the table?
Regards,
Thomas
I will add a feature request: "TRUNCATE should reset the identity
columns as in MySQL and MS SQL Server (and possibly other databases)."
Regards,
Thomas
This also seems to work for PostgreSQL and HSQLDB. It fails for Derby
and H2. I will add a feature request (patches are welcome of course):
drop table t;
create table t(a int);
-- supposed to work
alter table t add constraint x primary key(a);
drop table t;
create table t(a int);
insert into t values(1);
-- supposed to work
alter table t add constraint x primary key(a);
drop table t;
create table t(a int);
insert into t values(null);
-- not supposed to work
alter table t add constraint x primary key(a);
Regards,
Thomas