--- On Mon, 12/24/07, Henrique Pantarotto <[EMAIL PROTECTED]> wrote:
> I tried searching the documentation and mailing list, and I
> couldn't
> figure this one out.
ALTER TABLE questions
ALTER COLUMN answers TYPE possible_answers;
Actually your type is fine. you only need to alter the column
I would still recommend to keep the meanings associated with the values
in the database somehow.
Have you given thought to CHECK constraints? They are easier to alter on
the fly:
create table questionnare( Q varchar(256), A varchar(16)
constraint possible_answers check ( A IN( 'yes',
Thanks a lot Gurjeet! I understanded your suggestion... that seems to
work indeed. But I really would like to be able to alter the enum type
on the fly, so instead of using enum, I think I'll just use a "smallint"
type and tie the "possible results" to the application using flags such
as 0, 1, 2
Here's a possible solution (this may take long time if the table is too
big). The trick is to add a new column with a newly defined datatype, that
picks up values from the old column. Here's the sample psql script (the
session output follows after that):
create type possible_answers as enum ( 'yes
On Mon, Dec 24, 2007 at 04:10:45PM -0200, Henrique Pantarotto wrote:
> Hi Richard,
>
> I actually want to change the enum values after I have created and
> associated it to a table colum.
>
> Is it possible?
No. An enum is defined by its members. You can't change a type after it
is created, not
--- On Mon, 12/24/07, Henrique Pantarotto <[EMAIL PROTECTED]> wrote:
> I actually want to change the enum values after I have
> created and
> associated it to a table colum.
It looks like you will have to drop the type and re-create it.
You might have to try a couple of tests:
1) BEGIN TRANSACT
Hi Richard,
I actually want to change the enum values after I have created and
associated it to a table colum.
Is it possible?
Thanks.
On Mon, 24 Dec 2007 09:50:09 -0800 (PST)
Richard Broersma Jr <[EMAIL PROTECTED]> wrote:
> --- On Mon, 12/24/07, Henrique Pantarotto <[EMAIL PROTECTED]> wrote:
--- On Mon, 12/24/07, Henrique Pantarotto <[EMAIL PROTECTED]> wrote:
> I tried searching the documentation and mailing list, and I
> couldn't
> figure this one out.
ALTER TABLE questions
ALTER COLUMN answers TYPE possible_answers;
Actually your type is fine. you only need to alter the column
Hi,
I was wondering how can I alter an ENUM type? I have created a table
like this:
create type possible_answers as enum('yes', 'no');
create table questions ( question text, answers possible_answers);
insert into questions values ('Do you like me?', 'yes');
So my question is... How can I chang