Re: Error dropping non-existent tables

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Baldeep Hira <baldeephira(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Error dropping non-existent tables
Date: 2004-11-20 20:03:54
Message-ID: 20041120200354.GA25088@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Nov 20, 2004 at 10:15:46 -0800,
Baldeep Hira <baldeephira(at)gmail(dot)com> wrote:
> How do I move the "DROP TABLE" commands into a separate transaction? I
> could move all the "DROP TABLE" commands into a separate sql-script
> file, but then I never know which of the tables are existing in the
> database, thus that script will break as well. When I execute a
> bunch of SQL commands from a script file, do all of them form a single
> transaction? Anyway, I can have multiple transactions from a single
> script file?

Just like you do below. You will get error messages for the failed drops,
but everything will still work correctly. Were you actually having a problem
other than seeing the error message?

>
> Currently my sql-script file looks like this.
>
> DROP TABLE table1 CASCADE;
> DROP TABLE table2 CASCADE;
> DROP TABLE table3 CASCADE;
> DROP TABLE table4 CASCADE;
>
> CREATE TABLE table1 (
> name VARCHAR(255) NOT NULL,
> id INTEGER NOT NULL
> );
>
> CREATE TABLE table2 (
> id INTEGER NOT NULL,
> type INTEGER NOT NULL
> );
>
> CREATE TABLE table3 (
> id INTEGER NOT NULL,
> p_id INTEGER NOT NULL,
> CONSTRAINT fk_table3 FOREIGN KEY (id)
> REFERENCES table2 (id)
> );
>
> CREATE TABLE table4 (
> id INTEGER NOT NULL,
> name VARCHAR(255) NOT NULL,
> CONSTRAINT pk_table4 PRIMARY KEY (id),
> CONSTRAINT u_table4 UNIQUE (name)
> );

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jason C. Wells 2004-11-20 21:10:09 Problem Downloading for FreeBSD
Previous Message Baldeep Hira 2004-11-20 18:15:46 Re: Error dropping non-existent tables