Re: query for schema existence and create schema in jdbc?

From: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
To: "Hiller, Dean (Contractor)" <dean(dot)hiller(at)broadridge(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: query for schema existence and create schema in jdbc?
Date: 2011-01-21 15:25:39
Message-ID: AANLkTi=uAUAFg2pY6woKiCLrF24kw-FsJfCqE9kVn1QH@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Fri, Jan 21, 2011 at 6:14 AM, Hiller, Dean (Contractor) <
dean(dot)hiller(at)broadridge(dot)com> wrote:

> I need a way(and don’t care if it is not portable) to
>
>
>
> 1. Query to see if a schema exists or not
>
> 2. Create the schema if it doesn’t exist
>
> 3. Drop and recreate the schema if it does exist
>
>
>
> ALL through JDBC. Is this possible?
>

run this query, which returns a boolean:

select exists (select * from pg_catalog.pg_namespace where nspname =
'new_schema');

then either execute 'create schema new_schema;' or 'drop schema new_schema
cascade; create schema new_schema;'

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Lukas Eder 2011-01-25 07:39:51 Re: [HACKERS] Fwd: Weird issues when reading UDT from stored function
Previous Message Hiller, Dean (Contractor) 2011-01-21 14:30:00 Re: query for schema existence and create schema in jdbc?