I am seeing this behavior with IDENTITY COLUMN alter statements.
CREATE TABLE "SAMPLE "."ID" (
"KEYCOL" BIGINT NOT NULL GENERATED BY DEFAULT AS
IDENTITY (
START WITH +1
INCREMENT BY +1
MINVALUE +999
MAXVALUE +9223372036854775807
NO CYCLE
CACHE 100000
NO ORDER ) ,
"DWCONTRACTID" BIGINT NOT NULL )
IN "STAGE_32K" ;
INSERT INTO SAMPLE.ID (KEYCOL) VALUES (1001);
DB20000I The SQL command completed successfully.
SELECT * FROM SAMPLE.ID;
KEYCOL DWCONTRACTID
-------------------- --------------------
1 1001
1 record(s) selected.
db2 "alter table sample.id alter keycol restart with 100"
DB20000I The SQL command completed successfully.
db2 "insert into sample.id (dwcontractid) values (1002)"
DB20000I The SQL command completed successfully.
db2 "select * from sample.id order by 2"
KEYCOL DWCONTRACTID
-------------------- --------------------
1 1001
100 1002
2 record(s) selected.
db2 "alter table vijay.id alter keycol set cache 100000"
DB20000I The SQL command completed successfully.
db2 "insert into vijay.id (dwcontractid) values (1003)"
DB20000I The SQL command completed successfully.
db2 "select * from vijay.id order by 2"
KEYCOL DWCONTRACTID
-------------------- --------------------
1 1001
100 1002
100100 1003
3 record(s) selected.
--- Everything works good so far ----
Below is the problem!
db2 "alter table sample.id alter keycol restart with 999"
DB20000I The SQL command completed successfully.
db2 "alter table sample.id alter keycol set cache 100000"
DB20000I The SQL command completed successfully.
db2 "insert into sample.id (dwcontractid) values (1004)"
DB20000I The SQL command completed successfully.
db2 "select * from sample.id order by 2"
KEYCOL DWCONTRACTID
-------------------- --------------------
1 1001
100 1002
100100 1003
1 1004
4 record(s) selected.
If you see above, the KEYCOL IDENTITY value is reset to 1, I set the
RESTART value to 999 and followed that alter statement with CACHE set
to 1000000. Whenever the two alter statements are executed back to
back, the IDENTITY column value is reset to 1 irrespective of the
RESTART VALUE.
Is this by design?
Thank you for time & effort in advance.
Vijay
Could you provide a true repro?
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
It's table sample.ID all the way. I wanted to substitute my name
"vijay" with "sample" for schema name in the posting...
What you see in the initial posting is the true repro.
Thanks!
Vijay
I have the script tested and here is the output, still the same
problem! I see the problem in V8 FP12 & V9 FP2.
DROP TABLE SAMPLE.ID
DB20000I The SQL command completed successfully.
CREATE TABLE "SAMPLE "."ID" ( "KEYCOL" BIGINT NOT NULL GENERATED BY
DEFAULT AS IDENTITY ( START WITH +1 INCREMENT BY +1 MINVALUE +999
MAXVALUE +9223372036854775807 NO CYCLE CACHE 100000 NO ORDER ) ,
"DWCONTRACTID" BIGINT NOT NULL ) IN "STAGE_1_ALL"
DB20000I The SQL command completed successfully.
delete from sample.id
SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result
of a
query is an empty table. SQLSTATE=02000
insert into sample.id (dwcontractid) values (1001)
DB20000I The SQL command completed successfully.
alter table sample.id alter keycol restart with 100
DB20000I The SQL command completed successfully.
insert into sample.id (dwcontractid) values (1002)
DB20000I The SQL command completed successfully.
select * from sample.id order by 2
KEYCOL DWCONTRACTID
-------------------- --------------------
1 1001
100 1002
2 record(s) selected.
alter table sample.id alter keycol set cache 100000
DB20000I The SQL command completed successfully.
insert into sample.id (dwcontractid) values (1003)
DB20000I The SQL command completed successfully.
select * from sample.id order by 2
KEYCOL DWCONTRACTID
-------------------- --------------------
1 1001
100 1002
100100 1003
3 record(s) selected.
alter table sample.id alter keycol restart with 999
DB20000I The SQL command completed successfully.
alter table sample.id alter keycol set cache 100000
DB20000I The SQL command completed successfully.
insert into sample.id (dwcontractid) values (1004)
DB20000I The SQL command completed successfully.
select * from sample.id order by 2
KEYCOL DWCONTRACTID
-------------------- --------------------
1 1001
100 1002
100100 1003
1 1004
4 record(s) selected.
Thank you.
Vijay
OK, I agree that is not working properly. Can you open a PMR?
If support sends you around refer them to me.