Is "IF EXISTS" legit in "ALTER TABLE ... RENAME"?

From: Ken Winter <ken(at)sunward(dot)org>
To: PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Cc: Ken Winter <ken(at)sunward(dot)org>
Subject: Is "IF EXISTS" legit in "ALTER TABLE ... RENAME"?
Date: 2015-02-16 21:33:19
Message-ID: CABV8-AZ9aCOv5DNXCF2YRNgVtqefJbeSu4wEkjwGOG7b0SJ=-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

According to the PG 9.1 doc (
http://www.postgresql.org/docs/current/static/sql-altertable.html) this is
a valid flavor of ALTER TABLE:

ALTER TABLE [ IF EXISTS ] name
RENAME TO new_name

But when I try to execute such a command, I get:

ERROR: syntax error at or near "EXISTS"
LINE 1: ALTER TABLE IF EXISTS event
^
QUERY: ALTER TABLE IF EXISTS event
RENAME TO event_s;
CONTEXT: PL/pgSQL function "convert_table_to_history" line 60 at EXECUTE
statement

As you'll see, in this case the command was issued from a function. But
issuing it directly evokes the same error.

?!?

~ Thanks in advance
~ Ken

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-02-16 21:44:06 Re: Is "IF EXISTS" legit in "ALTER TABLE ... RENAME"?
Previous Message Adrian Klaver 2015-02-16 20:21:02 Re: Starting new cluster from base backup