Re: [GENERAL] creating tables in tablespace - Mailing list pgsql-general

From Tiffany Thang
Subject Re: [GENERAL] creating tables in tablespace
Date
Msg-id CAB_W-NNGp9qH_OW2Oo-x0vB89fiJ6G9iWzF9T7FO8-X=u-dTZQ@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] creating tables in tablespace  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [GENERAL] creating tables in tablespace  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Thanks Tom. As the superuser, I'm able to create the table in the specific tablespace. Does myuser require additional privileges?

My aim is to be able to create table in a specific tablespace (in this case, mytablespace) by default without having to explicitly specific one. I would think that is possible but I'm having trouble making it happen.

postgres=# create table postgrestab (a int) tablespace mytablespace;
CREATE TABLE

postgres=# select tablename,tableowner,tablespace from pg_tables where tablename like 'post%';
  tablename  | tableowner |  tablespace
-------------+------------+--------------
 postgrestab | postgres   | mytablespace
(1 row)

Thanks.

On Thu, Aug 24, 2017 at 2:46 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Tiffany Thang <tiffanythang@gmail.com> writes:
> According to the documentation, a table can be created in a specific
> tablespace by performing the following:
> 1. Specify the tablespace parameter in the create database statement.
> 2. Specify the tablespace parameter in the create table statement.

> I've tried both but the tablespace column in pg_tables is empty.

An empty entry in pg_tables means the table is in the database's
default tablespace, whether you made it that way implicitly or explicitly.
So this looks as-expected to me.  You'd need to spread the database across
more than one tablespace to get anything in that column.

> "show default_tablespace" is also empty.

If you didn't do anything to change that setting, that would also be
expected.  Again, the interpretation is "use the database's default
tablespace".

                        regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] creating tables in tablespace
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] creating tables in tablespace