Re: Dealing with schema in psql utility?

From: Tariq Muhammad <tmuhamma(at)libertyrms(dot)com>
To: Dan Delaney <ddelaney(at)powercreative(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Dealing with schema in psql utility?
Date: 2003-02-20 19:23:39
Message-ID: Pine.LNX.4.21.0302201411590.15424-100000@genesis.int.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thu, 20 Feb 2003, Dan Delaney wrote:

> 1) get a list of the schema that have been created in the current
> database

select * from pg_namespace ;

> 2) View the list of tables in a schema other than "public"?

Fist get the oid of the schema that you want to get the table list for :

select oid from pg_namespace where nspname = 'schema_name';

then

select relname from pg_class where relnamespace = oid; ## above oid.

> 3) Rename a schema (is there an "alter schema" statement)?

You can do it as superuser

update pg_namespace set nspname='new_schema_name' where
nspname='schema_name';

_/_/ _/_/ _/_/ Tariq Muhammad
_/ _/ _/ _/ _/ _/ tariq(at)libertyrms(dot)info
_/ _/ _/_/_/ _/_/_/ v:416-646-3304 x 111
_/ _/ _/ _/ _/ _/ c:416-455-0272
_/_/_/ _/_/_/ _/ _/ p:416-381-1457
_________________________________________________
Liberty Registry Management Services Co.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-02-20 19:28:16 Re: A problem with sequences...
Previous Message Bruno Wolff III 2003-02-20 19:23:01 Re: Fwd: REWRITE_INVOKE_MAX and "query may contain cycles"