Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

276
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda