I have created a table in derby Netbeans and now i realize that i need to make a column as auto incremented by 1 which is a primary key. How can i do so? I tried the following code but was in vain.
ALTER TABLE ISSUERECIPT ALTER IRCODE SET INCREMENT BY 1;
Do i need to create the table once again or can it be possible some other way?
I guess could do the things for you
Recreate the table again see example below:
ALTER TABLE tbl ADD id INT PRIMARY KEY AUTO_INCREMENT;
I have found an alternate solution, i dropped the column from the database (thanks vels4j) added the column once again from the netbeans derby UI as shown below:
Try this :
To alter the column to be auto-generated, the code is
BUT the column must already be defined with the IDENTITY attribute (as written in this documentation).
In most cases (assuming that you too), the primary key column is not set as IDENTITY. Therefore, you may intend to alter the column to IDENTITY, but that is impossible.
The only way is to drop the table and create it again, as written here.