Reiniciar serial en PostgreSQL
- netoec84
- PostgreSQL
- May 15, 2014
- auto increment, bdd, bigserial, postgresql, psql, serial
Si se desea reiniciar una columna numérica autoincremental del tipo SERIAL o BIGSERIAL se puede utilizar la siguiente sentencia SQL:
ALTER SEQUENCE <tabla>_<id>_seq RESTART WITH 1
Por ejemplo, para la tabla «usuarios» sería:
ALTER SEQUENCE usuarios_id_seq RESTART WITH 1