ungalnanban
ungalnanban

Reputation: 10327

how to change default min sequence value for database

I have this doubt, how to configure the default min value for sequence in postgresql? Is it possible?

I want to change the default min value of sequence in Postgresql for all my table in a database. I don't like to use CREATE SEQUENCE and ALTER SEQUENCE because I don't want to do manual work. If I create new table with sequence. that automatically should take the min value is 1000 instead of 1, after configured this If i create a sequence it should take default min val is 1000 (configured value)

Where I need to configure the min val and max value for sequence in Postgresql. Is there any variable in Postgresql.conf file.

Upvotes: 0

Views: 282

Answers (1)

Frank Heikens
Frank Heikens

Reputation: 127446

Is there any variable in Postgresql.conf file.

No, there isn't. You have to ALTER the sequence or use SETVAL() to set the value you need.

You could change the source code of PostgreSQL that creates the sequences and compile your own version of PostgreSQL, that will fix it for every sequence you ever create in your database.

Upvotes: 1

Related Questions