I'm trying to create a database and tables in a custom tablespace, but instead 'pg_default' tablespace is used for tables. Here's example:
mkdir /data
chown postgres /data
CREATE TABLESPACE mytspace OWNER postgres LOCATION '/data';
CREATE DATABASE mydb WITH OWNER = postgres ENCODING = 'UTF8' LC_COLLATE = 'ru_RU.utf8' LC_CTYPE = 'ru_RU.utf8' TABLESPACE = mytspace CONNECTION LIMIT = -1;
CREATE TABLE foo(i int) TABLESPACE mytspace;
psql's \db
command shows that tablespace is created
List of tablespaces
Name | Owner | Location
------------+----------+---------------
mytspace | postgres | /data
pg_default | postgres |
pg_global | postgres |
(3 rows)
Database created in appropriate tablespace. Here's SQL i see in pgAdmin:
CREATE DATABASE mydb
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'ru_RU.utf8'
LC_CTYPE = 'ru_RU.utf8'
TABLESPACE = mytspace
CONNECTION LIMIT = -1;
But table created in 'pg_default" tablespace
CREATE TABLE foo
(
i integer
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
What should I do to create a 'foo' table in 'mytspace' tablespace?