Обсуждение: No relations found?

Поиск
Список
Период
Сортировка

No relations found?

От
"Mikael Carneholm"
Дата:
After upgrading to the 7.3 version and putting one of my databases
in a custom schema, I found out that the psql command

\d
(just \d, with no object specified)

reports 'No relations found', while

\d schemaname.tableFoo

displays the table information for tableFoo (and DbVisualizer sees
the table + other tables as well)

Strange, isn't it? I mean, shouldn't \d display all schemas &
their tables in the current database?



Re: No relations found?

От
Joe Conway
Дата:
Mikael Carneholm wrote:
> After upgrading to the 7.3 version and putting one of my databases
> in a custom schema, I found out that the psql command
>
[snip]
>
> Strange, isn't it? I mean, shouldn't \d display all schemas &
> their tables in the current database?
>

No, it should display only the tables that are in the schemas in your
search_path. See:
   http://developer.postgresql.org/docs/postgres/runtime-config.html
(SEARCH_PATH (string) near the bottom)

To see your current search_path:

regression=# show search_path;
  search_path
--------------
  $user,public
(1 row)

Here $user is a macro which evaluates to the logged in user name. To change
your search path for a particular session:

regression=# create schema foo;
CREATE SCHEMA
regression=# create table foo.bar(f1 int);
CREATE TABLE
regression=# \d bar;
Did not find any relation named "bar".
regression=# set search_path to 'foo','public';
SET
regression=# \d bar;
        Table "foo.bar"
  Column |  Type   | Modifiers
--------+---------+-----------
  f1     | integer |

To change the search path for all users and databases, change search_path in
postgresql.conf. To change it persisently for one database, all users see the
ALTER DATABASE command:

regression=# ALTER DATABASE regression SET search_path TO 'foo','public';
ALTER DATABASE

To change the search path persisently for one user, see the ALTER USER command:
regression=# ALTER USER user1 SET search_path TO 'foo','public';
ALTER USER

HTH,

Joe