Thread: Working with partition tables

Working with partition tables

From
John Scalia
Date:
Hi all,

We’re having a bit of a problem getting a partitioned table altered. The parent table has two partitions, which we have
detachedfrom it. The parent, however, refuses to be altered, as the parent still shows it is partitioned by its list
attribute,I.e. from \d+ 

Partition key: LIST(batched)

Is there any way to remove the partition key, or do we simply need to create a new table with the structure we need,
dropthe old one, then rename the new one to that original name and reattach the partitions? 

The docs on this seem a bit unclear on this issue.
—
Jay
Sent from my iPad


Re: Working with partition tables

From
"David G. Johnston"
Date:
On Thu, Nov 12, 2020 at 9:18 AM John Scalia <jayknowsunix@gmail.com> wrote:
Is there any way to remove the partition key, or do we simply need to create a new table with the structure we need, drop the old one, then rename the new one to that original name and reattach the partitions?
 
I'm not super familiar with partitioning but...you can probably do it in the reverse order and avoid the rename.  A partitioned table without partitions seems useless so just drop it, then create a new one with the same name with the correct defintion.

The documentation is indeed clear though you may be looking in the wrong spot:
"It is not possible to turn a regular table into a partitioned table or vice versa."

David J.

Re: Working with partition tables

From
John Scalia
Date:
Thanks David, I had only looked at the docs for v.11, as that is what we’re running, and I didn’t see this line. 

We decided to use a Create table temp (LIKE original); and make the alterations there, then create a third table from like the temp but with partitioning, did the same for each partition, then linked those as partitions to the new temp with the partitioning enabled. Finally, we just renamed that third temp to the original name. Was just hoping for a less circuitous route.

Sent from my iPad

On Nov 12, 2020, at 11:25 AM, David G. Johnston <david.g.johnston@gmail.com> wrote:


On Thu, Nov 12, 2020 at 9:18 AM John Scalia <jayknowsunix@gmail.com> wrote:
Is there any way to remove the partition key, or do we simply need to create a new table with the structure we need, drop the old one, then rename the new one to that original name and reattach the partitions?
 
I'm not super familiar with partitioning but...you can probably do it in the reverse order and avoid the rename.  A partitioned table without partitions seems useless so just drop it, then create a new one with the same name with the correct defintion.

The documentation is indeed clear though you may be looking in the wrong spot:
"It is not possible to turn a regular table into a partitioned table or vice versa."

David J.