Re: A conditional DROP TABLE function - Mailing list pgsql-general

From Tino Wildenhain
Subject Re: A conditional DROP TABLE function
Date
Msg-id 3F89785D.7050807@wildenhain.de
Whole thread Raw
In response to A conditional DROP TABLE function  (David Link <dvlink@yahoo.com>)
Responses Re: A conditional DROP TABLE function
List pgsql-general
Hi David,

David Link wrote:
> Hi All,
>
> Here's a Conditional drop_table func for those interested.  There was a
> thread on this a long time back.
>
> We do this all the time :
>
>   DELETE TABLE sales;
>   CREATE TABLE sales (...);
>
Hm. "all the time" enables all the warning lights -
what are you doing to have to delete and create
the tables every time?

> But nobody likes
>
>   ERROR:  table "sales" does not exist
>
> which we see all the time in the logs.  I want to show the logs to none
> db folk -- so we can't have those error messages in it.

grep -v "ERROR" should do it.

>
> (There must be some explaination why postgresql (and Oracle as well) do
> not have CREATE OR REPLACE TABLE as it does for VIEWs, and FUNCTIONs.
> Anybody know?)

Nobody needs this?
There is:

1) delete from table;
2) truncate table;

to remove all the data

3) alter table ...

to change tables layout.

HTH
Tino Wildenhain


pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Redhat RPMs (Was: Debian experimental packages
Next
From: Tom Lane
Date:
Subject: Re: Temporary tables and miscellaneous schemas