Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tC3dM-00AH33-Ar for pgsql-general@arkaria.postgresql.org; Fri, 15 Nov 2024 21:13:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tC3dJ-00Bn7Y-Oq for pgsql-general@arkaria.postgresql.org; Fri, 15 Nov 2024 21:13:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tC3dI-00Bn0T-6j for pgsql-general@lists.postgresql.org; Fri, 15 Nov 2024 21:13:37 +0000 Received: from fhigh-b8-smtp.messagingengine.com ([202.12.124.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tC3dF-0025Gm-Fx for pgsql-general@postgresql.org; Fri, 15 Nov 2024 21:13:35 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 208AD254011C; Fri, 15 Nov 2024 16:13:32 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Fri, 15 Nov 2024 16:13:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1731705211; x=1731791611; bh=N6mU7zxg6COwAZPb6Z7X43nmWhWrSdO1MYLCB18hRog=; b= kPNp4B50fE3obVXzkstmR90phe0z2Y4yJIKOfB2oILt5EPfVlwMFK9Ndxkax7JOj c3kqiWEAjQXfLXt8FAyjYoAQzsnIW1u1mPph6z30eoTK5ZV8QCm5x8Jy2vUXnjRr Rs50IbWMD0DNkYuYwzu/wV5v0+yn7tgXPynfxUu+j3+M1mjkLU8FVtmRjeUViKQ0 P5VfIAqA3PNXWdRj6KKxNDA3YDf7B0fqrT59djUinPRHSKjOdgXgqcoMR3GfYdRU 3EbFcFbPkB9us7McslLxs/cjvBhRbraYxOCRYIS2djakXV61LfBs+kvweiwv1bKX HQTSsJsGDazPEc25ZmD69A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1731705211; x=1731791611; bh=N 6mU7zxg6COwAZPb6Z7X43nmWhWrSdO1MYLCB18hRog=; b=gvMdsPXRgUyZ3tjFF W6TMlBNTZw1pj1BlkpjBRR4dhg21qGFWupcPIMMSb96ZlBKTHeqqCkZlGT2nINH5 snT3ILoGleOFieWVNV1+k5FAgPFN6p/Ku/8jnadlhNbVFeIQRsEdcnwhYXMR0RXe TmW/kSGIS0Eh42bBJy5nVu5ydDO8A+/By2JOObD8pQMVfFm6Ju4cE1GO6t4CVa26 RCeJdTHVcyO+tFCwffpSWDEYIb2eX/QywgJF9fLQFqinD98HUe1tXmsDL+y3R0iz pwb5zvIgdULrjvwyjOBUh1fLVo+aMskExNq7PvSkLENF/q7vmGEmBHrz9q/4o9b2 U68lA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrvdeggddugeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeen ucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrse grkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeelgeevkeekkeeuiefgtdev ieeluefhfedufeetkeejffekjeeujeehgeehgeektdenucffohhmrghinhepphhoshhtgh hrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspg hrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvghsthgvvghm sghsvhdqfhhorhhumheshigrhhhoohdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvg hnvghrrghlsehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 15 Nov 2024 16:13:31 -0500 (EST) Message-ID: <389718a6-b146-40bd-be7c-1f6a427cec0c@aklaver.com> Date: Fri, 15 Nov 2024 13:13:30 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Need exact SQL query to find List of Detach Partitioned Tables (Yet to be Dropped) To: Bharani SV-forum , "pgsql-general@postgresql.org" References: <0558ddd4d71641bdb41fa49b2425f73c@safrangroup.com> <98965993.3138805.1731699978332@mail.yahoo.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <98965993.3138805.1731699978332@mail.yahoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 adrian.klaver@aklaver.com