pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Maxim Maletsky <maxim@japaninc.com>
To: 'Philip Hallstrom' <philip@adhesivemedia.com>
To: Jason Watkins <jason_watkins@pobox.com>
Cc: pgsql-sql@postgresql.org
Subject: RE: Re: drop table if exists
Date: Tue, 17 Jul 2001 19:16:11 +0900
Message-ID: <DC017B079D81D411998C009027B7112A015ED3E6@EXC-TYO-01> (raw)

Alright, but what about when you're writing a long dump file with all these
sequences, functions not speaking about the tables themselves.
When I drop something I wanna make sure it out the database (but still
cannot empty the whole database before), so I have 

DROP TABLE ..., ..., ..., ...;
DROP FUNCTION ..., ..., ..., ...;
DROP SEQUENCE ..., ..., ..., ...;

If one of these were not there, the whole dump crashes and I need to restart
the process modifying the SQL file.

I'd LOVE to have a magic 'IF EXISTS' like in mySQL - make life easier
(Although I totally disrespect mySQL).
Has anyone a work around for this?

Thanks,
and yes, sorry for the late post, just looked you up guys.


Sincerely, 

 Maxim Maletsky
 Founder, Chief Developer
 PHPBeginner.com (Where PHP Begins)
 maxim@phpbeginner.com
 www.phpbeginner.com



-----Original Message-----
From: Philip Hallstrom [mailto:philip@adhesivemedia.com]
Sent: Wednesday, July 04, 2001 7:39 AM
To: Jason Watkins
Cc: pgsql-sql@postgresql.org
Subject: [SQL] Re: drop table if exists


Just drop the table using "DROP TABLE mytable;" and ignore the error...
I'm sure there are fancy ways of doing it by accessing system tables, but
the above works for me.

On Tue, 3 Jul 2001, Jason Watkins wrote:

> How can I duplicate the behavior of:
>
> DROP TABLE IF EXISTS mytable;
>
> CREATE TABLE mytable (
> blah,
> blah
> );
>
> INSERT INTO mytable
> (blah)
> VALUES
> (blah);
>
> in other words, so that I have a single sql file that restores the
database
> to a known state.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



view thread (4+ messages)

Message-ID: <DC017B079D81D411998C009027B7112A015ED3E6@EXC-TYO-01>
Permalink:  ../DC017B079D81D411998C009027B7112A015ED3E6@EXC-TYO-01/
Also on:    postgresql.org/message-id/DC017B079D81D411998C009027B7112A015ED3E6@EXC-TYO-01

 · 

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-sql@postgresql.org
  Cc: maxim@japaninc.com, philip@adhesivemedia.com, jason_watkins@pobox.com
  Subject: Re: drop table if exists
  In-Reply-To: <DC017B079D81D411998C009027B7112A015ED3E6@EXC-TYO-01>
  References: <DC017B079D81D411998C009027B7112A015ED3E6@EXC-TYO-01>

* 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