I have a PostgreSQL table with the following structure:
I simply need to change the TYPE
of prove_identity_id
from bigint
to bigserial
. I read the docs but wasn't able to understand how to legally achieve the change without the following error: PostgreSQL said: type "bigserial" does not exist
PostgreSQL 10.1 on x86_64-apple-darwin14.5.0, compiled by Apple LLVM version 7.0.0 (clang-700.1.76), 64-bit
Best Answer
bigserial
is not a type. It's a pseudo-type, a notational convenience that is resolved to typebigint
internally, plus a sequence, a column default, a dependency and an ownership.Basic commands to convert an existing
bigint
column with existing rows to abigserial
:setval()
to get theSEQUENCE
in sync with the currently highest id. Replace "tbl" with your table name (prove_identity
).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.More details:
Related:
In Postgres 10 or later, consider an
IDENTITY
column as alternative: