From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Kevin Brannen <KBrannen@efji.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: syntax error with alter type
Date: Fri, 7 Dec 2018 15:33:02 -0800
Message-ID: <60cd0448-2940-d9ac-3b52-3be8563f7b88@aklaver.com> (raw)
In-Reply-To: <SN1PR19MB0255E21F90F7B01FBD4CF835A4AA0@SN1PR19MB0255.namprd19.prod.outlook.com>
References: <SN1PR19MB0255E21F90F7B01FBD4CF835A4AA0@SN1PR19MB0255.namprd19.prod.outlook.com>
On 12/7/18 3:17 PM, Kevin Brannen wrote:
> I’m running Pg 9.6.5 if it matters…
>
> I’m trying to drop a value from an ENUM (type) and it seems like I’m
> following the fine manual yet I still get an error. For example:
>
> nms=# create type alphabet as enum ('a', 'b', 'c', 'd');
>
> CREATE TYPE
>
> nms=# alter type alphabet drop attribute if exists 'c';
>
> ERROR: 42601: syntax error at or near "'c'"
>
> LINE 1: alter type alphabet drop attribute if exists 'c';
>
> ^
>
> LOCATION: scanner_yyerror, scan.l:1086
>
> What am I doing wrong? The goal is to get rid of the ‘c’ value from the
> enum. Yes, you can assume I’ve already removed of all the ‘c’ values in
> the table where it’s used.
https://www.postgresql.org/docs/10/datatype-enum.html
"Although enum types are primarily intended for static sets of values,
there is support for adding new values to an existing enum type, and for
renaming values (see ALTER TYPE). Existing values cannot be removed from
an enum type, nor can the sort ordering of such values be changed, short
of dropping and re-creating the enum type.
>
> Or does that statement not do what I think it does and I have to do the
> “create new type, change the table to use the new type, drop old type,
> rename new type to old type” routine?
>
> Thanks,
>
> Kevin
>
> This e-mail transmission, and any documents, files or previous e-mail
> messages attached to it, may contain confidential information. If you
> are not the intended recipient, or a person responsible for delivering
> it to the intended recipient, you are hereby notified that any
> disclosure, distribution, review, copy or use of any of the information
> contained in or attached to this message is STRICTLY PROHIBITED. If you
> have received this transmission in error, please immediately notify us
> by reply e-mail, and destroy the original transmission and its
> attachments without reading them or saving them to disk. Thank you.
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, KBrannen@efji.com
Subject: Re: syntax error with alter type
In-Reply-To: <60cd0448-2940-d9ac-3b52-3be8563f7b88@aklaver.com>
References: <SN1PR19MB0255E21F90F7B01FBD4CF835A4AA0@SN1PR19MB0255.namprd19.prod.outlook.com> <60cd0448-2940-d9ac-3b52-3be8563f7b88@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox