Pergunta

I have an already existing table which I want to partition, looking at the documentation I see that this cannot happen, so I re-created the table and try to partition that:

CREATE TABLE tableB (LIKE tableA INCLUDING ALL) PARTITION BY range (field1_in_tableA, field2_in_tableA);

but I am getting:

ERROR:  insufficient columns in PRIMARY KEY constraint definition
DETAIL:  PRIMARY KEY constraint on table "tableB" lacks column "field1_in_tableA" which is part of the partition key.

Is there any workaround to this?

Foi útil?

Solução

If you have a primary key, then you can't partition by a key which is not part of the primary key. Do you want a primary key on the new table? If so, you have to either add field1_in_tableA to the primary key, or remove it from the partitioning key.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a dba.stackexchange
scroll top