How can I increment this id, by 4 instead of 1 as it does by default using SQLAlchemy + Postgres? I'm using SQLAlchemy, Postgres, and Alembic.
id = Column(BigInteger, primary_key=True)
How can I increment this id, by 4 instead of 1 as it does by default using SQLAlchemy + Postgres? I'm using SQLAlchemy, Postgres, and Alembic.
id = Column(BigInteger, primary_key=True)
Get the name of the underlying SEQUENCE
for your serial
column and change its increment:
SELECT pg_get_serial_sequence('tbl', 'id');
Then:
ALTER SEQUENCE tbl_id_seq INCREMENT 4; -- replace with actual name
Or with a single integrated DO
statement:
DO
$$BEGIN
EXECUTE format('ALTER SEQUENCE %s INCREMENT 4'
, pg_get_serial_sequence('tbl', 'id');
END$$;
Related: