pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedWorking with partition tables
3+ messages / 2 participants
[nested] [flat]
* Working with partition tables
@ 2020-11-12 16:18 John Scalia <jayknowsunix@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: John Scalia @ 2020-11-12 16:18 UTC (permalink / raw)
To: pgsql-admin
Hi all,
We’re having a bit of a problem getting a partitioned table altered. The parent table has two partitions, which we have detached from 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, drop the 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Working with partition tables
@ 2020-11-12 16:24 David G. Johnston <david.g.johnston@gmail.com>
parent: John Scalia <jayknowsunix@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: David G. Johnston @ 2020-11-12 16:24 UTC (permalink / raw)
To: John Scalia <jayknowsunix@gmail.com>; +Cc: pgsql-admin
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:
https://www.postgresql.org/docs/13/ddl-partitioning.html
"It is not possible to turn a regular table into a partitioned table or
vice versa."
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Working with partition tables
@ 2020-11-12 17:42 John Scalia <jayknowsunix@gmail.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: John Scalia @ 2020-11-12 17:42 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-admin
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:
> https://www.postgresql.org/docs/13/ddl-partitioning.html
> "It is not possible to turn a regular table into a partitioned table or vice versa."
>
> David J.
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-11-12 17:42 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 16:18 Working with partition tables John Scalia <jayknowsunix@gmail.com>
2020-11-12 16:24 ` David G. Johnston <david.g.johnston@gmail.com>
2020-11-12 17:42 ` John Scalia <jayknowsunix@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox