Does SQL Server 2005 have an equivalent to MySql#39;s ENUM data type?(SQL Server 2005 是否具有等效于 MySql 的 ENUM 数据类型?)
问题描述
我正在处理一个项目,我想在表中存储一些易于枚举的信息.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 数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server 2005 是否具有等效于 MySql 的 ENUM 数据类型?


基础教程推荐
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01