If you liked this site, please feel free to help me out with the upkeep!

Get Firefox!

Valid HTML 4.01 Transitional

Home > Programming > PostgreSQL Stuff

Bigserial does not exist

Although you can create tables with columns of Bigserial you can't alter columns to said type. I got around it like so...

CREATE SEQUENCE my_column_seq;

ALTER TABLE my_table ALTER COLUMN my_column_id TYPE bigint, ALTER COLUMN my_column_id SET default nextval('my_column_id_seq'::regclass)

Either select the current max sequence value or make sure the sequence is set to one more than the current max my_column_id, e.g. if it's 500, set to 501.

SELECT setval('my_column_id_seq', (SELECT max(my_column_id) FROM my_table));

ALTER sequence my_column_id_seq RESTART WITH 501 INCREMENT BY 1