From: | Tiffany Thang <tiffanythang(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | creating tables in tablespace |
Date: | 2017-08-24 18:31:33 |
Message-ID: | CAB_W-NO43G-c=SEdMqvcBBjF2J_u=0eaZqn8tavR2qQRcZjosQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I'm not able to create tables in a specific tablespace. I'm not sure what I
have missed.
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. "show
default_tablespace" is also empty. Can someone help?
Thanks.
As the superuser,
create tablespace mytablespace owner myuser location '/pgsqldata/mydb';
create database mydb owner=myuser tablespace=mytablespace;
As myuser,
mydb=> select current_user;
current_user
--------------
myuser
(1 row)
mydb=> create table tab1 (a int);
CREATE TABLE
mydb=> create table tab2 (a int) tablespace mytablespace;
CREATE TABLE
mydb=> show default_tablespace;
default_tablespace
--------------------
(1 row)
mydb=> select tablename,tableowner,tablespace from pg_tables where
tablename like 'tab%';
tablename | tableowner | tablespace
-----------+------------+------------
tab1 | myuser |
tab2 | myuser |
(2 rows)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-08-24 18:46:08 | Re: creating tables in tablespace |
Previous Message | Dmitry Lazurkin | 2017-08-24 15:11:01 | Change location of function/type installed from C-extension |