DB creation script questions

From: "Jon Horsman" <horshaq(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: DB creation script questions
Date: 2006-08-16 18:44:58
Message-ID: 4f4c2a010608161144v61381db8m2d9148915673757d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hey All,

I'm new to postgres and am wondering what the recommended way of
creating an automated db creation script is. I've reading the
postgres 8.1 manual but haven't seen much on this and google doesn't
seem to be bringing up much either.

I need to create a script that will create a database if it currently
doesn't exist on the system. It will then create tables if they don't
already exist and populate the tables with some data if this data
doesn't currently exist. This script must be able to be run over an
over without causing harm to the db.

I have previously used MySQL and was able to accomplish this very
simply using IF NOT EXISTS for the table and database creation but
this doesn't seem to be available for postgres and i'm looking for a
more robust solution anyways.

Is there a way that from a sql script file/shell script you can find
out if certain postgres tables/databases exist?

If someone can point me in the right direction it would be greatly appreciated.

Thanks,

Jon.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2006-08-16 19:07:24 Re: OT: OpenDatabase Model ?
Previous Message Tom Lane 2006-08-16 16:58:12 Re: Using bitmap index scans-more efficient