I want to create a table in a PostgreSQL database on a given schema. The table is defined like this:
CREATE TABLE ventajon.altas_sorteo_crucero (
id_alta serial NOT NULL,
fecha timestamp without time zone NOT NULL,
nombre character varying(100) NOT NULL,
apellidos character varying(100) NOT NULL,
cifnif character varying(50) NOT NULL,
email character varying(320) NOT NULL,
telefono character varying(50) NOT NULL
) WITH (
OIDS=FALSE
);
I'm not a guru with PostgreSQL so, for now, if I want to restart the autoincremental value represented by the id_alta column, I open a SQL console and execute this:
ALTER SEQUENCE ventajon.altas_sorteo_crucero_id_alta_seq RESTART WITH 1;
However, I would like to know if it could be possible to set a predefined value for the sequence itself. What if I need for id_alta to start at, let's say, 50? Or... what if I want to tell this table to admit any insertion as long as the id_alta falls between 50 and 250?
It's perfectly ok if I need to accomplish this like I do right now, in two queries. Just... I would like to know if this could be accomplished in a single step.
Is it possible?