Archive for the ‘mysql’ Category

Migrating sequences to Postgres

Sunday, August 17th, 2008

When moving a database from mysql to postgres, it’s often necessary to reset the sequences (.i.e. autoupdated row ids)

Find out what the largest one is with select max (id) from mytable;

Set the sequence with select setval('mytable_id_seq',x+1) ;