Re: why schema name is same as username behaves different

From: Joe Conway <mail(at)joeconway(dot)com>
To: Jie Liang <jie(at)stbernard(dot)com>
Cc: 'Bruce Momjian' <pgman(at)candle(dot)pha(dot)pa(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-admin(at)postgresql(dot)org
Subject: Re: why schema name is same as username behaves different
Date: 2002-12-05 23:44:15
Message-ID: 3DEFE4CF.9070301@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Jie Liang wrote:
> ####I expect to see something like:
> List of relations
> Schema | Name | Type | Owner
> --------+------+-------+-------
> public | foo | table | robot
> t | foo | table | robot

That's because schema t is not in your search path. By default,
search path is:

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

So you are not seeing the table in schema foo. If you do:
regression=# create user robot;
CREATE USER
regression=# create schema t AUTHORIZATION robot;
CREATE SCHEMA
regression=# drop table foo;
DROP TABLE
regression=# create table foo(test text);
CREATE TABLE
regression=# create table t.foo(test text);
CREATE TABLE
regression=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------+-------+----------
public | foo | table | postgres
public | table1 | table | postgres
public | table2 | table | postgres
(3 rows)

regression=# set search_path to 't','public';
SET
regression=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------+-------+----------
public | table1 | table | postgres
public | table2 | table | postgres
t | foo | table | postgres
(3 rows)

The $user in the default search path allows user robot to automatically find
objects in schema robot first.

You can change the default search path for the installation in
postgresql.conf, or you can change in via ALTER DATABASE or ALTER USER to be
effective in just one database or for one user respectively.

HTH,

Joe

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jie Liang 2002-12-05 23:45:51 Re: why schema name is same as username behaves different then ot
Previous Message Peter Eisentraut 2002-12-05 23:21:45 Re: list schema