From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Alex Williams <valenceshell@protonmail.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Tablespace column value null on select * from pg_tables
Date: Mon, 15 Jul 2019 12:22:39 -0700
Message-ID: <a61ac18f-df1b-1bb5-ca3c-346bc8faf464@aklaver.com> (raw)
In-Reply-To: <HF3MoPAEJHO5WGoMH1JsvhqzV3P48GQ8vOwKhad1xCLbC5-SOgGYDSmEOJFtFNARBPreyEGiuWKaI3pU2j8n7NG8kMDS41elKfD_qxB-AxY=@protonmail.com>
References: <HF3MoPAEJHO5WGoMH1JsvhqzV3P48GQ8vOwKhad1xCLbC5-SOgGYDSmEOJFtFNARBPreyEGiuWKaI3pU2j8n7NG8kMDS41elKfD_qxB-AxY=@protonmail.com>
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 <https://protonmail.com; Secure Email.
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, valenceshell@protonmail.com
Subject: Re: Tablespace column value null on select * from pg_tables
In-Reply-To: <a61ac18f-df1b-1bb5-ca3c-346bc8faf464@aklaver.com>
References: <HF3MoPAEJHO5WGoMH1JsvhqzV3P48GQ8vOwKhad1xCLbC5-SOgGYDSmEOJFtFNARBPreyEGiuWKaI3pU2j8n7NG8kMDS41elKfD_qxB-AxY=@protonmail.com> <a61ac18f-df1b-1bb5-ca3c-346bc8faf464@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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