On Tue, Oct 9, 2012 at 9:04 PM, Robert Haas <robertmh...@gmail.com> wrote: > I've been a big proponent of adding "IF EXISTS" support to CREATE > TABLE and ALTER TABLE but I'm having a hard time getting excited about > this one. I can't imagine that many people would use it
The reason CREATE IF NOT EXISTS and DROP IF EXISTS are so useful is because they're shortcuts for ensuring some specific state is always true. Regardless of whether the table existed before, now it does or doesn't as desired. (The concern about create was in fact specifically that it wouldn't guarantee that the same table definition would exist afterwards) The same is not true of TRUNCATE IF EXISTS. In that case after the command has run either the table exists and is empty or it doesn't exist and still needs to be created. I take it the intended use is something like TRUNCATE IF EXISTS foo; CREATE IF NOT EXISTS foo... So perhaps what we really need is a CREATE OR TRUNCATE foo(...), but just plain TRUNCATE IF EXISTS doesn't seem to make sense. -- greg -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers