Thread: enumeration type?
This occurred to me yesterday as I was designing a little Db. Has anyone thought about support for a simple enumeration type creation mechanism? I know I could do it with CREATE TYPE and input/output functions, but that does seem like a lot of work for a smallish thing. As it is, I settled on a char type with some constraint checking, but couldn't help thinking how nice a simple enumeration would have been. andrew
There is no such thing as an enumeration type. What there is is the char type with a CHECK constraint. MySQL made up ENUMs out of whole cloth...they should copy our way, not us theirs... Chris ----- Original Message ----- From: "Andrew Dunstan" <andrew@dunslane.net> To: "PostgreSQL Hackers Mailing List" <pgsql-hackers@postgresql.org> Sent: Sunday, June 15, 2003 4:49 AM Subject: [HACKERS] enumeration type? > This occurred to me yesterday as I was designing a little Db. > > Has anyone thought about support for a simple enumeration type creation > mechanism? I know I could do it with CREATE TYPE and input/output functions, > but that does seem like a lot of work for a smallish thing. > > As it is, I settled on a char type with some constraint checking, but > couldn't help thinking how nice a simple enumeration would have been. > > andrew > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes: > MySQL made up ENUMs out of whole cloth...they > should copy our way, not us theirs... ENUMs do seem to have some advantages in convenience though. And providing them or something closely comparable would ease porting from MySQL ... which is an important consideration in our plan for world domination ;-) In short I wouldn't object to having this on the TODO list. It's just not real high priority in my mind. regards, tom lane
Tom Lane writes: > ENUMs do seem to have some advantages in convenience though. And > providing them or something closely comparable would ease porting > from MySQL ... which is an important consideration in our plan for > world domination ;-) Now that domains have check constraints, I think enumerations can be easily created without having to invent nonstandard features. There's also the advantage that you can create domains out of data types other than text. -- Peter Eisentraut peter_e@gmx.net