public inbox for [email protected]  
help / color / mirror / Atom feed
From: Adrian Klaver <[email protected]>
To: Bharani SV-forum <[email protected]>
To: [email protected] <[email protected]>
Subject: Re: Need exact SQL query to find List of Detach Partitioned Tables (Yet to be Dropped)
Date: Fri, 15 Nov 2024 13:13:30 -0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>

On 11/15/24 11:46, Bharani SV-forum wrote:
>   Team
> 
> Need exact SQL query to find List of Detach Partitioned Tables (Yet to 
> be Dropped)
> 
> The following is the query which i used, i am using and i found an bug 
> which is listing an newly created table (last week)

As David G. Johnston said how would you know it was formally a partition?:

https://www.postgresql.org/docs/current/sql-altertable.html

"
DETACH PARTITION partition_name [ CONCURRENTLY | FINALIZE ]

     This form detaches the specified partition of the target table. The 
detached partition continues to exist as a standalone table, but no 
longer has any ties to the table from which it was detached.

[...]
"

The only I could see this working is if you had a standard naming scheme 
for partitions and then you could do a regex search in pg_class for that 
pattern where relkind = 'r'.

> 
> SELECT relnamespace::regnamespace::text AS schema_name, relname AS 
> table_name
> FROM   pg_class c
> WHERE  NOT relispartition  -- !
> AND    relkind = 'r' and lower(relnamespace::regnamespace::text) not in 
> ('pg_catalog','partman','information_schema')  and
> lower(relnamespace::regnamespace::text) in ('XYZ')
> order by  relnamespace::regnamespace::text, relname ;

-- 
Adrian Klaver
[email protected]







view thread (61+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Need exact SQL query to find List of Detach Partitioned Tables (Yet to be Dropped)
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox