pg_castalog.pg_tables does not show the real tablespace for tables

pg_castalog.pg_tables does not show the real tablespace for tables

am 07.04.2009 13:23:57 von murojc

--0016e6da7b064087350466f5406d
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi!
I have created a tablespace and a database in that tablespace:

create tablespace tb_user location '/data/tb_user';
create database mydatabase tablespace "tb_user";
\c mydatabase;
create table a_table (id bigint, name text);

I supposed that "a_table" should be in the tablespace "tb_user" as the
database was created to use it by default. But I doesnt seem like that when
i state the next:

mydatabase=# select tablename,tablespace from pg_catalog.pg_tables where
tablename='a_table';
tablename | tablespace
-----------+------------
a_table |

Why?
I can imagine that the table was really created in tb_user tablespace, as i
realize that there were created new files under the /data/tb_user directory.

The database seems to have been properly created for that tablespace:

Name | Owner | Encoding | Tablespace | Description
------------+----------+----------+------------+------------ ---------------
mydatabase | postgres | UTF8 | tb_user |
postgres | postgres | UTF8 | pg_default |
template0 | postgres | UTF8 | pg_default |
template1 | postgres | UTF8 | pg_default | default template database

Is there a way to see where real tablespace for a given table?
Thanks in advance!!
J. Carlos Muro

--0016e6da7b064087350466f5406d
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi!
I have created a tablespace and a database in that tablespace:
<=
br>

cr=
eate tablespace tb_user location '/data/tb_user';
create databas=
e mydatabase tablespace "tb_user";

\c mydatabase;
create table a_table (id bigint, name text);
>I supposed that "a_table" should be in the tablespace "tb_u=
ser" as the database was created to use it by default. But I doesnt se=
em like that when i state the next:


ew,monospace;">mydatabase=3D# select tablename,tablespace from pg_catalog.p=
g_tables where tablename=3D'a_table';

y: courier new,monospace;">
=A0tablename | tablespa=
ce

ont-family: courier new,monospace;">-----------+------------
e=3D"font-family: courier new,monospace;">
=A0a_table   | n>

Why?
I can imagine that the table was really created in=
tb_user tablespace, as i realize that there were created new files under t=
he /data/tb_user directory.

The database seems to have been properly created for that tablespace:
r>
=A0=
   Name  =A0 |=A0 Owner   | Encoding | Tablespace |    =
  =A0 Description
------------+----------+----------+------------+--=
-------------------------

=A0mydatabase | postgres | UTF8     | tb_user  =A0 |
=A0post=
gres   | postgres | UTF8     | pg_default |
=A0template0=A0 =
| postgres | UTF8     | pg_default |
=A0template1=A0 | postgres =
| UTF8     | pg_default | default template database


Is there a way to see where real tablespace for a given table? >Thanks in advance!!
J. Carlos Muro



--0016e6da7b064087350466f5406d--

Re: pg_castalog.pg_tables does not show the real tablespace for tables

am 07.04.2009 16:33:46 von Tom Lane

"J. Carlos Muro" writes:
> I have created a tablespace and a database in that tablespace:

> create tablespace tb_user location '/data/tb_user';
> create database mydatabase tablespace "tb_user";
> \c mydatabase;
> create table a_table (id bigint, name text);

> I supposed that "a_table" should be in the tablespace "tb_user" as the
> database was created to use it by default. But I doesnt seem like that when
> i state the next:

The database's default tablespace is never named explicitly in pg_tables
nor in the underlying pg_class catalog. This is intentional to make it
easier to move a database to a different default tablespace.

regards, tom lane

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin