代表我的对象的正确 SQL 数据类型是什么?

发布于 2024-11-19 08:40:44 字数 411 浏览 11 评论 0原文

我的对象是一个字符串,实现为 1-50 个 US-ASCII 数据 字符的数组。

  1. 我应该使用什么 SQL 数据类型来在我的数据库表中表示这一点?
    • 我正在使用 SQL Server Express 2008。(这有关系吗?)
  2. 是否代表 扩展 ASCII 需要与表示标准 ASCII 不同的数据类型?

My object is a string, implemented as an array of 1-50 US-ASCII data characters.

  1. What SQL Data Type should I use to represent this in my database table?
    • I am using SQL Server Express 2008. (Does that matter?)
  2. Does representing Extended ASCII require a different datatype than representing Standard ASCII?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生生漫 2024-11-26 08:40:44

如果您需要可变长度 US-ASCII 字段(最多 50 个字符),请使用 VARCHAR(50)。如果要使用 Unicode,则需要使用 NVARCHAR(50)

varchar[(n|max)]

可变长度、非 Unicode 字符数据。 n 可以是 1 到 8,000 之间的值。 max表示最大存储大小为2^31-1字节。存储大小为输入数据的实际长度+2字节。输入的数据长度可以是 0 个字符。 varchar 的 ISO 同义词是 char Varvaring 或Character Varvaring。

和:

使用 char 或 varchar 的对象被分配数据库的默认排序规则,除非使用 COLLATE 子句分配特定排序规则。排序规则控制用于存储字符数据的代码页。


nvarchar [ ( n | max ) ]

可变长度 Unicode 字符数据。 n 可以是 1 到 4,000 之间的值。 max表示最大存储大小为2^31-1字节。存储大小(以字节为单位)是输入字符数的两倍 + 2 字节。输入的数据长度可以是 0 个字符。 nvarchar 的 ISO 同义词是National char Varing 和National Character Varying。

If you need a variable length US-ASCII field (up to 50 characters), use VARCHAR(50). If you want to use Unicode, you need to use NVARCHAR(50).

varchar [ ( n | max ) ]

Variable-length, non-Unicode character data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of data entered + 2 bytes. The data entered can be 0 characters in length. The ISO synonyms for varchar are char varying or character varying.

And:

Objects that use char or varchar are assigned the default collation of the database, unless a specific collation is assigned using the COLLATE clause. The collation controls the code page that is used to store the character data.


nvarchar [ ( n | max ) ]

Variable-length Unicode character data. ncan be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size, in bytes, is two times the number of characters entered + 2 bytes. The data entered can be 0 characters in length. The ISO synonyms for nvarchar are national char varying and national character varying.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文