nvarchar(MAX) 可以容纳的最大字符数是多少? [英] What is the maximum number of characters that nvarchar(MAX) will hold?
问题描述
我是 nvarchar(MAX)
概念的新手.它将容纳多少个字符?
I'm new to the concept nvarchar(MAX)
. How many characters will it hold?
推荐答案
Max.容量是 2 GB 的空间 - 因此您看到的 2 字节字符正好超过 10 亿个,可以放入 NVARCHAR(MAX)
字段.
Max. capacity is 2 gigabytes of space - so you're looking at just over 1 billion 2-byte characters that will fit into a NVARCHAR(MAX)
field.
使用其他答案的更详细的数字,您应该能够存储
Using the other answer's more detailed numbers, you should be able to store
(2 ^ 31 - 1 - 2) / 2 = 1'073'741'822 double-byte characters
1 billion, 73 million, 741 thousand and 822 characters to be precise
在您的 NVARCHAR(MAX)
列中(不幸的是,最后半个字符被浪费了...)
in your NVARCHAR(MAX)
column (unfortunately, that last half character is wasted...)
更新: 正如@MartinMulder 指出的那样:任何可变长度字符列也有 2 字节的开销来存储实际长度 - 所以我需要从 2 ^ 中减去两个字节31 - 1
长度是我之前规定的 - 因此你可以存储比我之前声明的少 1 个 Unicode 字符.
Update: as @MartinMulder pointed out: any variable length character column also has a 2 byte overhead for storing the actual length - so I needed to subtract two more bytes from the 2 ^ 31 - 1
length I had previously stipulated - thus you can store 1 Unicode character less than I had claimed before.
这篇关于nvarchar(MAX) 可以容纳的最大字符数是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!