pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Murthy Kambhampaty <murthy.kambhampaty@goeci.com>
To: Sam Carleton <ehc@linux-info.net>
To: pgsql-admin@postgresql.org
Subject: Re: sql scripts
Date: Mon, 20 Oct 2003 14:33:24 -0400
Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC092444@THOR.goeci.com> (raw)

If it's a bash script you could use:

#####
SomeTable=<Table you're about to create>
TableTest=$(psql -d <your new db> -U <its owner> -ntc "select relname from
pg_class where relname='$SomeTable'")
[[ -n "$TableTest" ]] && psql -d <your new db> -U <its owner> -nc "drop
table $SomeTable"
#####


It's not quite "in postgres's sql", but it could get the job done


>-----Original Message-----
>From: Sam Carleton [mailto:ehc@linux-info.net]
>Sent: Saturday, October 18, 2003 22:37
>To: pgsql-admin@postgresql.org
>Subject: [ADMIN] sql scripts
>
>
>I am new to postgres and your mailing lists, please let me know if I
>am posting in the wrong list.
>
>I am working on creating my first database in Postgres.  In the
>script that will create all the tables for the firs time, I would
>like to have a conditional statement to delete a table, if it
>already exists.  I know the other databases create such a condtional
>statement for you when you export the schema.  What would such a
>conditional statement look like in Postgres's sql?
>
>sam
>
>---------------------------(end of 
>broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>      subscribe-nomail command to majordomo@postgresql.org so that your
>      message can get through to the mailing list cleanly
>



view thread (4+ messages)  latest in thread

Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC092444@THOR.goeci.com>
Permalink:  ../2D92FEBFD3BE1346A6C397223A8DD3FC092444@THOR.goeci.com/
Also on:    postgresql.org/message-id/2D92FEBFD3BE1346A6C397223A8DD3FC092444@THOR.goeci.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: murthy.kambhampaty@goeci.com, ehc@linux-info.net
  Subject: Re: sql scripts
  In-Reply-To: <2D92FEBFD3BE1346A6C397223A8DD3FC092444@THOR.goeci.com>
  References: <2D92FEBFD3BE1346A6C397223A8DD3FC092444@THOR.goeci.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox