[TLM] Re: [GENERAL] how to alter an enum type

2007-12-27 Thread Richard Broersma Jr
--- 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 on

Re: [GENERAL] how to alter an enum type

2007-12-26 Thread Henrique Pantarotto
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, 3

Re: [GENERAL] how to alter an enum type

2007-12-26 Thread Gurjeet Singh
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',

Re: [GENERAL] how to alter an enum type

2007-12-25 Thread Gurjeet Singh
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 (

[GENERAL] how to alter an enum type

2007-12-24 Thread Henrique Pantarotto
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

Re: [GENERAL] how to alter an enum type

2007-12-24 Thread Richard Broersma Jr
--- 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 on

Re: [GENERAL] how to alter an enum type

2007-12-24 Thread Henrique Pantarotto
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:

Re: [GENERAL] how to alter an enum type

2007-12-24 Thread Richard Broersma Jr
--- 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 TRANSACTION;

Re: [GENERAL] how to alter an enum type

2007-12-24 Thread Martijn van Oosterhout
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 for