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

103
Visualizações
How can multiple unique in partition tabale?

I have a SQL table like below.

CREATE TABLE my_table 
(
    id serial,
    user_id int,
    order_no character varying(50),
    date_time timestamp,
    primary key (id, user_id, date_time),
    unique(user_id, order_no)
) PARTITION BY RANGE (date_time);

I have a table. I need to unique order_no column with user_id column. there is no any problem.

But I have to unique data_time column because of I use partition. but date_time column has to be separated with user_id and order_no.

By the way I don't want like this unique (user_id, order_no, data_time)

How can I unique date_time in this table ?

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

0

There is no way to create a unique index or constraint that guarantees that order_no or user_id are unique. That is one of the drawbacks of partitioning.

You could create unique constraints on the partitions. While that doesn't guarantee global uniqueness, it goes a long way.

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