Re: How can I detect if a schema exists?

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: felix(at)crowfix(dot)com
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: How can I detect if a schema exists?
Date: 2013-01-10 00:11:59
Message-ID: CAB8KJ=iornCwNQGTPS=YRdaVOnvJ545Kqi=Oz5OUR-AmEX3+zw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2013/1/10 <felix(at)crowfix(dot)com>

> I was reviving an old test program which hasn't been used since 9.1 and
> found that "SET search_path = xyzzy" no longer fails if the schema "xyzzy"
> doesn't exist.
>
> Is there an approved or recommended way to tell if a schema exists? I can
> think of lots of ways, but none as easy as the 9.1 search_path. I suppose
> I shouldn't rely on undocumented features ...
>

How about:

SELECT TRUE FROM information_schema.schemata WHERE schema_name = 'xyzzy'

? (Though I notice this table only seems to show the schemas owned by the
user if the user is not a superuser).

Ian Lawrence Barwick

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2013-01-10 00:15:15 Re: Error: absolute path not allowed
Previous Message felix 2013-01-09 22:39:47 How can I detect if a schema exists?