Avatar of dimensionav
dimensionav
Flag for Mexico asked on

Create postgresql sequence for database ids

Hi!

We imported a MySQL database and, since in postgre there isn't Autoincrement options, we need to create a serial.

The thing is, the current exported id's doesn't allow us to change its type from int to a serial, instead of  that, Postgresql is asking to create a sequence and set the default value as the nextval of that sequence

Is there any more efficient way to do it?

Regards!
PostgreSQLDatabasesMySQL Server

Avatar of undefined
Last Comment
earth man2

8/22/2022 - Mon
Doug Walton

As far as I know, that's the only way to do it which is kind of annoying.

If you have to do this a ton of times you could try creating a procedure that would take a table and column name as parameters that would do it for you.
ASKER CERTIFIED SOLUTION
earth man2

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes