Search Postgresql Archives

best way to handle enum type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey everybody. I have a field that, in my earlier mySQL days would have been an enum('q','y','m','c'), and I'm wondering what's the best way to handle this in pgsql. I've googled enough to find out that pgsql doesn't have a built in enum type (it's of course possible that what I read was outdated, please let me know if it was), but I've found a couple popular workarounds, the first being

CHECK (favourite_colour IN ('red', 'blue', 'yellow', 'purple'))

as well as a suggestion to create another small table containing the possible values and then placing

color text references color

in the create table sql. Now this field doesn't absolutely have to be an enum, I'm sure I could work with matching the values to numbers and making it an int. What I'm wondering is what's generally considered 'best practice' for this situation. I'd like to have a solid db more than an enum type, what's my best move?

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux