Autoincrement="true" in Oracle vs Postgres

Hello,

I have that (autoincrement=“true”) in a column which is a generated ID. This creates a sequence in both Oracle and Postgres. The issue is that in postgres the name of the Sequence is “tablecolumn_seq” and in oracle is a random string.
Is there any chance to set that name to be the same without having computedValue?

Hi, michey! Thanks for posting this question.

I did a little searching and found someone with a similar issue on a StackOverflow thread, and this was a suggested solution for them:

After the sequence’s already created, we can call NEXTVAL(‘table_id_seq’) to generate a new value automatically.

1. Link the sequence to the unique column

ALTER TABLE ONLY 
ALTER COLUMN id 
SET DEFAULT NEXTVAL('table_id_seq');
ALTER TABLE ONLY table
    ADD CONSTRAINT table_id PRIMARY KEY (id);

If this does not answer your question, or if you’ve resolved it another way, please let us know.

Regards,
Tabby

1 Like