Re: "truncate all"? - Mailing list pgsql-hackers

From Josh Berkus
Subject Re: "truncate all"?
Date
Msg-id 200308050855.03721.josh@agliodbs.com
Whole thread Raw
In response to Re: "truncate all"?  (Andreas <e9625203@student.tuwien.ac.at>)
Responses Re: "truncate all"?
List pgsql-hackers
Andi,

> Another way to specify a safe but efficient "TRUNCATE ALL" command that
> might be easier to implement than above "TRUNCATE table
> [CASCADE|RESTRICT]"  might be to implement the functionality of the
> originally suggested "TRUNCATE ALL" through a psql meta-command. Any
> suggestions for a safe syntax of such a "TRUNCATE ALL" meta-command? How
> about "\rtuples *"?

I'm not clear on the usefulness of this idea.   If we agree that TRUNCATE ... 
CASCADE is needed, then doing it in SQL makes sense.  Your suggested command 
would leave itself open to typo-death.

And if we have TRUNCATE ... CASCADE, then truncating all tables is a matter of 
a very simple perl or C script looping through pg_class.

The reason I'm opposed to "TRUNCATE ALL" is that it provides an opportunity 
for ghastly mistakes.   I also don't think that outside of your particular 
case that there's much demand for it; most users, I imagine, want to truncate 
a group of tables or all but 2 tables or are already used to DROP DATABASE 
and don't need it.   You could take a quick survey on PGSQL-SQL.

> Before attempting to implementing any such extension, we would like to
> make sure that that extension would not be rejected by those of you who
> decide what goes into future versions of postgresql.

That's definitely good idea ... make sure it gets on the TODO list before 
submitting.  Been around a while, have you?

-- 
Josh Berkus
Aglio Database Solutions
San Francisco


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Release changes
Next
From: Lee Kindness
Date:
Subject: Re: --enable-thread-safety broken + patch regressions