If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to change max value of identity column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-19-10, 23:39
phanita phanita is offline
Registered User
 
Join Date: Sep 2009
Posts: 14
Red face How to change max value of identity column

Hi,

I've created table by mistake.

CREATE TABLE TEST (
DEF_ID BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 32672 NO CYCLE CACHE 20),
PROPERTY_NAME VARCHAR(50) NOT NULL
)


It has MAXVALUE for IDENTITY But i was too small can I increase max or actually I would like to drop the max value is that posible?

Thank you in advance.
Reply With Quote
  #2 (permalink)  
Old 01-20-10, 02:28
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The manual states which modifications can be done on an IDENTITY column: Modifying the generated or identity property of a column

If you try an "ALTER TABLE ... ALTER COLUMN ... SET GENERATED BY DEFAULT AS IDENTITY ( MAXVALUE 65536 )", you get an error SQL0190. The explanation for that error states:
Quote:
* If SET GENERATED ALWAYS AS IDENTITY or SET GENERATED BY DEFAULT AS
IDENTITY is specified, the column is already defined with a form of
generation (default, identity, or expression) and there is no
corresponding DROP in the same statement.
Combining this with the above, you have to drop the identity property from the column and re-add.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 01-20-10, 03:49
phanita phanita is offline
Registered User
 
Join Date: Sep 2009
Posts: 14
Thank you for the replied.

After re-add the identity. The identity is restart to 1 but i still have data in the table. Do you know how to restart identity?
Reply With Quote
  #4 (permalink)  
Old 01-20-10, 05:59
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You use a different value in the "START WITH 1" clause.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On