I need to specify a id column that is generated automatically. The table already exists and has an enormous amount of data. Also it is very hard to get the permission for stopping the application on the production environment. I want to update the table on the fly.
Is it possible to change am existing table and enrich it with Identity functionality? Suddenly the official Documentation only states how to create an identity column, not how to alter it to an identity.
If not is it possible to simulate the functionality with sequences and triggers?
-- current schema of the table
CREATE TABLE nl_status(
identificationnumber BIGINT NOT NULL PRIMARY KEY,
status varchar(25)
);
--desired functionality
CREATE TABLE nl_status(
identificationnumber BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
status varchar(25)
);
You can try this one-time logic to convert it into an identity column.