r d <rd0002@gmail.com> writes:
> My Database C1 definition:
> CREATE DATABASE "C1" ...
> TABLESPACE = "C1"
> After these two statements, tablespace C1 should be the default tablespace
> for storing all objects in database C1, meaning that when I do not specify
> a tablespace, objects are stored there. Right?
Right.
> I now proceed to do:
> CREATE TABLE "TEMP1"
> (
> "ID" bigint NOT NULL,
> CONSTRAINT "PK_TEMP1" PRIMARY KEY ("ID" )
> );
> That makes a table "TEMP1" in tablespace C1. Ok so far.
> *But it creates the index of the PK in tablespace "pg_default" !!!*
Um ... not for me. AFAICS, nothing is created under $PGDATA/base
when I do this. And both the table and the index show up in pg_class
with reltablespace = 0:
d1=# select relname,reltablespace from pg_class where relname like '%TEMP%';
relname | reltablespace
----------+---------------
TEMP1 | 0
PK_TEMP1 | 0
(2 rows)
which is the correct way of indicating they belong to the database's
default tablespace. Are you perhaps misinterpreting the zero as meaning
they'll be in pg_default?
regards, tom lane