I have a serial column created as follows:
CREATE TABLE public.table_name (
"_id" serial4 NOT NULL,
The assumption I had, is that this column will have only sequential values, i.e. 1, 2, ..., n, where n- is the total number of rows in table table_name. However, this is not the case:
SELECT max(_id), count(*) FROM public.table_name;
yields:
959132 111933
I know that the assumption I had is most probably an erroneous one, but can you please show me the correct way to achieve what I am after, and preferably also how to update the already non-sequential values to make them sequential.
Postgres version:
PostgreSQL 13.2 (Ubuntu 13.2-1.pgdg18.04+1)
1,42,3673628,-363or something else. Gaps are expected and nothing to worry about. Just move on.serialdoes not rollback when a transaction does, it just moves on.