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

220
Visualizações
Postgres Bigserial Datatype

I am trying to create Postgres table with Bigserial data type as a promary key. Once I am creating the table the table definition is getting changed to bigint NOT NULL DEFAULT nextval('transactions.transaction_id_seq'::regclass), to this. Please let me know why this happenning?

Thanks In Advance, Somnath

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

As noted in the documentation, serials are not "real" data types, but rather convenience wrappers. If you create a serial column, you automatically get

  • a new sequence ('tablename_columnname_seq`)
  • an integer column of the appropriate type that takes its default value from the sequence.
  • the setup for the column to use the sequence.

To quote:

The data types smallserial, serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns (similar to the AUTO_INCREMENT property supported by some other databases).

CREATE TABLE table (BIGSERIAL id PRIMARY KEY);

is the same as

CREATE SEQUENCE table_id_seq;
CREATE TABLE table (
   id bigint NOT NULL DEFAULT nextval('table_id_seq')
);
ALTER SEQUENCE table_id_seq OWNED BY table.id;

Which matches what you are getting.

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