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

239
Visualizações
Lista de particiones en Postgres 12
CREATE TABLE countrymeasurements ( countrycode int NOT NULL, countryname character varying(30) NOT NULL, languagename character varying (30) NOT NULL, daysofoperation character varying(30) NOT NULL, salesparts bigint, replaceparts bigint ) PARTITION BY LIST(countrycode) ( partition india values(1), partition japan values(2), partition china values(3), partition malaysia values(4) );

Recibo ERROR: error de sintaxis en o cerca de "(". Lo que me falta aquí. Estoy usando postgres12

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

0

No sé dónde encontraste esa sintaxis, obviamente no en el manual . Como puede ver , las particiones se crean usando create table .. as partition of en Postgres:

Defina la tabla:

 CREATE TABLE countrymeasurements ( countrycode int NOT NULL, countryname character varying(30) NOT NULL, languagename character varying (30) NOT NULL, daysofoperation character varying(30) NOT NULL, salesparts bigint, replaceparts bigint ) PARTITION BY LIST(countrycode);

Defina las particiones:

 create table india partition of countrymeasurements for values in (1); create table japan partition of countrymeasurements for values in (2); create table china partition of countrymeasurements for values in (3); create table malaysia partition of countrymeasurements for values in (4);
over 4 years ago · Santiago Trujillo Relatório

0

¡Bienvenido a stackoverflow! Tenga en cuenta que hacer preguntas aquí sin mostrar una investigación previa puede rechazar a personas que de otro modo les encantaría ayudar.

En este caso, verifiqué y no encontré ningún ejemplo oficial para la partición de listas. Pero, si simplemente acorta su declaración, creará una tabla usando los valores en la columna de countrycode de país para particionar:

 CREATE TABLE countrymeasurements ( countrycode int NOT NULL, countryname character varying(30) NOT NULL, languagename character varying (30) NOT NULL, daysofoperation character varying(30) NOT NULL, salesparts bigint, replaceparts bigint ) PARTITION BY LIST(countrycode) ;

El comando psql describe table muestra que la partición es la solicitada:

 psql=# \d countrymeasurements Table "public.countrymeasurements" Column | Type | Collation | Nullable | Default -----------------+-----------------------+-----------+----------+--------- countrycode | integer | | not null | countryname | character varying(30) | | not null | languagename | character varying(30) | | not null | daysofoperation | character varying(30) | | not null | salesparts | bigint | | | replaceparts | bigint | | | Partition key: LIST (countrycode)

Luego puede definir las particiones como en la respuesta de @a_horse_with_no_name. Pero, algunas notas sobre el uso de tal estrategia pueden estar en orden.

Notas:

  • Cuando solo permite 4 particiones explícitas a través de la lista (como lo intentó), ¿qué sucede cuando aparece el valor 5?
  • La documentación en postgresql 12 sobre la partición ddl sugiere considerar la partición hash en lugar de la lista y elegir la cantidad de particiones en lugar de confiar en los valores de su columna, lo que podría exponer una abundancia muy desequilibrada.
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