Re: Truncate if exists
От | Greg Stark |
---|---|
Тема | Re: Truncate if exists |
Дата | |
Msg-id | CAM-w4HOwYmv-035+uR05ud1DuUotse4_weMmGgkHft4bDVwmng@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Truncate if exists (Robert Haas <robertmhaas@gmail.com>) |
Ответы |
Re: Truncate if exists
|
Список | pgsql-hackers |
On Tue, Oct 9, 2012 at 9:04 PM, Robert Haas <robertmhaas@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
В списке pgsql-hackers по дате отправления: