我正在处理一个项目,我想在表中存储一些易于枚举的信息.MySql 的枚举数据类型正是我想要的:http://dev.mysql.com/doc/refman/5.0/en/enum.html .SQL Server 2005 中是否有等价物?
I'm working on a project and I want to store some easily enumerated information in a table. MySql's enum data type does exactly what I want: http://dev.mysql.com/doc/refman/5.0/en/enum.html . Is there an equivalent in SQL Server 2005?
我知道我可以用一个键将可能的值存储在一个类型表中,但我宁愿不必链接回它来进行描述.我们的数据库标准不允许我们在非整数或唯一标识符字段上进行链接,因此也无法将可能的键存储为字符.
I know I could store the possible values in a type table with a key, but I'd rather not have to link back to it for descriptions. Our database standards don't allow us to link on non-integer or uniqueidentifier fields, so storing the possible keys as characters is out as well.
这对您有用吗?
来自 http://blechie.com/wtilton/archive/2007/08/24/303.aspx
创建表...
MySQL:
ColumnName ENUM('upload', 'open', 'close', 'delete', 'edit', 'add')
DEFAULT 'open'
SQL Server:
ColumnName varchar(10)
CHECK(ColumnName IN ('upload', 'open', 'close', 'delete', 'edit', 'add'))
DEFAULT 'open'
这篇关于SQL Server 2005 是否具有等效于 MySql 的 ENUM 数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!