Category Archives: auto-increment

Is it possible to auto increment float in Apache Derby?

I'm looking to create two similar tables, both of which need an auto-increment function. It appears that on Apache Derby, you can only increment whole numbers like:

Create Table Mapping
(
id Integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
uname VARCHAR(30) NOT NULL
);

which runs successfully. I want to achieve this:

Create Table GMapping
(
gid Float PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1.00001, INCREMENT BY .00001),
gname VARCHAR(30) NOT NULL
);

which throws an error that 1.00001 and .00001 are not valid integer literals.

Is there a way to achieve this? If not that, could I possibly use auto increment for anything but Integer, SMALLINT, which doesn't need me to specify a whole number?

Thank you for your time. :)