Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

277
Vistas
Does postgres support to set start value at serial definition?

Here is a question about changing serial value with alter key word. Can this be done in create table defintion? Like that:

CREATE TABLE tablename (
    colname SERIAL stars 1000
);
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You can try this query.Its worked for me.

CREATE SEQUENCE tablename_colname_seq
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1 ---> here you can mention startup nummber as you need
  CACHE 1;

CREATE TABLE tablename (
    colname integer NOT NULL DEFAULT nextval('tablename_colname_seq')
);
over 4 years ago · Santiago Trujillo Denunciar

0

Identity Columns

There is no currently no way to do this in a CREATE TABLE command in PostgreSQL 9.x using the PostgreSQL-specific serial-type syntax. However, it's coming in PostgreSQL 10 using the standardized Identity Columns syntax, see my answer on it here

Here is how it will look

CREATE TABLE foo (
    id int GENERATED { ALWAYS | BY DEFAULT }
      AS IDENTITY [ ( sequence_options ) ]
);

Where (sequence_options) is START WITH 1000, so something like this.

CREATE TABLE foo (
  foo_id   int   GENERATED ALWAYS AS IDENTITY (START WITH 1000)
);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda