Does SQL Server 2008 have a a data-type like MySQL's enum
?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
The best solution I've found in this is to create a lookup table with the possible values as a primary key, and create a foreign key to the lookup table.
It doesn't. There's a vague equivalent:
Where performance matters, still use the hard values.
Found this interesting approach when I wanted to implement enums in SQL Server.
The approach mentioned below in the link is quite compelling, considering all your database enum needs could be satisfied with 2 central tables.
http://blog.sqlauthority.com/2010/03/22/sql-server-enumerations-in-relational-database-best-practice/
IMHO Lookup tables is the way to go, with referential integrity. But only if you avoid "Evil Magic Numbers" by following an example such as this one: Generate enum from a database lookup table using T4
Have Fun!