bigserial is not a type. It's a pseudo-type, a notational convenience that is resolved to type
bigint internally, plus a sequence, a column default, a dependency and an ownership.
Basic commands to convert an existing
bigint column with existing rows to a
CREATE SEQUENCE tbl_tbl_id_seq;
ALTER TABLE tbl ALTER COLUMN tbl_id SET DEFAULT nextval('tbl_tbl_id_seq');
ALTER SEQUENCE tbl_tbl_id_seq OWNED BY tbl.tbl_id;
SELECT setval('tbl_tbl_id_seq', COALESCE(max(tbl_id), 0)) FROM tbl;
setval() to get the
SEQUENCE in sync with the currently highest id. Replace "tbl" with your table name (
However, zooming into your added image (which should be plain text), it looks like it may be a proper
bigserial column already. This might all be a misunderstanding, then.
In Postgres 10 or later, consider an
IDENTITY column as alternative: