Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hn6Zm-0006CE-M5 for pgsql-general@arkaria.postgresql.org; Mon, 15 Jul 2019 19:23:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hn6Ym-0005sv-Jb for pgsql-general@arkaria.postgresql.org; Mon, 15 Jul 2019 19:22:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hn6Yk-0005rE-Ej for pgsql-general@lists.postgresql.org; Mon, 15 Jul 2019 19:22:52 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hn6Yc-00066C-Rb for pgsql-general@lists.postgresql.org; Mon, 15 Jul 2019 19:22:49 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E574322254; Mon, 15 Jul 2019 15:22:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 15 Jul 2019 15:22:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=o FJGkJY0PBuvoqr3dkhXxfnwArEAfn4SILJsrUTuBI0=; b=ksUvnIbanxlJYyd5S EIIpWjLikS8iMJxQG9VvbOSR7k7wenJ1c2mFt6gT8tvtOSKzbaUPPE3+CvmTz4GO jgq0S9w4c7MSMr7pjkJUlL2JcAsllpfLKFbrj0rvDPKh+kRNL+rZA/eiUg1Moq9D oWony0EBn7SykwbDcMcgdYnHK4BMlJplpS7JBqAxSsT4gCLB+tvL07QIFjwlrEoh abM7fb/IchfvzNXshquCByGe1BPwIVo11qPoexU6sRm0wOcbzObGCMrSBmPyfre3 1sE6H6scIEbcZYjBbtKyezWYb3fw9lo20daA5guwjqLJdtAklu4zYP+Mv5nXAr64 D9UOQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=oFJGkJY0PBuvoqr3dkhXxfnwArEAfn4SILJsrUTuB I0=; b=ST1z8iOwpywv3n4wwA0A6LSTzhy8q/a+43bCr1jwAeBW0yHJuTNINJG9j bPduZ6MteyFHVMA0XiOXZbkfrIKp3McSSXb4VSHreop5ytU6Nd49M69JKr7PLstl e4I3LOFFqaXLTg19rr/9mOsonD1V6Tlrx9Zkek68opicv0EQ2j+V9zPZLW1mzJny S7IWkOz7TPEf9xWFUahsMhUhzbqyXyjaki9mojHEC5p1EQPkj2L4jw/gkcDlUGqe eS+iI2LRKYdWwSpBKWKpatNHq3SpIWOVuXM5TWUCNkeD/Or37WkPrDloZMfMJivG rhhDWh64riqPvYYW6a6Exc5SKnOCA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrheekgddufedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtje ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuffhomhgrihhnpehprhhothhonhhmrg hilhdrtghomhdpphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvdduvddrudeh tddrvddtvdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrh esrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id EA4D780060; Mon, 15 Jul 2019 15:22:39 -0400 (EDT) Subject: Re: Tablespace column value null on select * from pg_tables To: Alex Williams , "pgsql-general@lists.postgresql.org" References: From: Adrian Klaver Message-ID: Date: Mon, 15 Jul 2019 12:22:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/15/19 11:35 AM, Alex Williams wrote: > Hi, > > Server Version 9.5 > > I found this old thread on something similar to the results I'm getting: > https://www.postgresql.org/message-id/1308615192339-4508750.post%40n5.nabble.com > > But in my case, I have a database that's in a user-defined tablespace > (data2) and all the tables/indexes there are also in data2 and I want to > do a select into a table the results of all the tables / tablespaces > they are in that database...when doing this: > > > SELECT distinct tablespace > FROM pg_tables; > > I get 2 rows: null and pg_global (I think to expect null for pg_default, > but if the table is in a user-defined tablespace, should we expect it to > show it, in my case, data2?) Not if you did: CREATE DATABASE name ... [ TABLESPACE [=] tablespace_name ] ALTER DATABASE name SET TABLESPACE new_tablespace This makes the tablespace the default for the database and the default shows up as null in pg_tables: https://www.postgresql.org/docs/9.5/view-pg-tables.html tablespace name pg_tablespace.spcname Name of tablespace containing table (null if default for database) > > or > > SELECT distinct tablespace > FROM pg_indexes > > I get 3 rows: null, pg_global and pg_default > > and this: SELECT * FROM pg_tablespace; > > I get 3 rows: pg_default, pg_global and data2. > > Using pgadmin, getting properties for the DB / tables, it shows data2. > > What I want to do is move all the tables / indexes from data2 to > pg_default (we added more space to the pg_default mount.) > > Now, I did a pg_dump/restore for one database which took a long time and > we now know the process for that, so on the next database we have we > want to do it where we use the following commands: > > ALTER DATABASE mydatabase SET TABLESPACE pg_default; > alter table all in tablespace data2 set tablespace pg_default; > > But, what I'm trying to accomplish here is, aside from checking the > filesystem, like df- h, to see it was moved or properties on each table > (too many) I just want to run a query that will insert into a table all > the tables and their tablespace names and when the above two commands > (3rd will be moving indexes) run the query again and verify everything > has moved from data2 to pg_default. > > Thanks for your help in advance. > > Alex > > > Sent with ProtonMail Secure Email. > -- Adrian Klaver adrian.klaver@aklaver.com