0

I have created table and provided primary key. (ADD COLUMN id SERIAL PRIMARY KEY).

In the postgres database, sometimes the sequence name is showing as table_column_seq1 and sometimes it is table_column_seq only.

Can anybody explain why this 1 is appending?

also using java program can I fetch this sequence name on this table column dynamically and change? I want to execute alter sequence script by getting its name through java program.

alter table mytable ADD COLUMN myid SERIAL PRIMARY KEY
Rajesh
  • 19
  • 1
  • 6
  • Note that standard compliant `identity` columns are recommended over the non-standard `serial` columns. –  Dec 02 '22 at 08:34
  • Can you please provide me any sample SQL for postgres which includes identity column ? please – Rajesh Dec 02 '22 at 08:41
  • "...sometimes the sequence name is..." - What difference does it make? When inserting rows, the JDBC API returns the new ID value automatically. No need to look at the sequence. – The Impaler Dec 02 '22 at 14:48
  • one of our requirement is to alter the sequence type from int to BIGINT, at that time we require the sequence name – Rajesh Dec 04 '22 at 10:40

0 Answers0