[英]SQL Server text, ntext, image data type problem
Microsoft announced that: " ntext
, text
, and image
data types will be removed in a future version of Microsoft SQL Server." 微软宣布:“将在未来版本的Microsoft SQL Server中删除
ntext
, text
和image
数据类型。” And advises to use nvarchar(max)
, varchar(max)
, and varbinary(max)
instead. 并建议改为使用
nvarchar(max)
, varchar(max)
和varbinary(max)
。
My question: I have a data type bigger than 8 kb. 我的问题:我的数据类型大于8 kb。 How can I insert this data to sql?
如何将此数据插入sql? Which data type will solve my problem?
哪种数据类型可以解决我的问题?
Any of nvarchar(max) , varchar(max) , and varbinary(max) . nvarchar(max) , varchar(max)和varbinary(max)中的任何一个 。
nvarchar(max) and varchar(max) are for textual information (with nvarchar having unicode support). nvarchar(max)和varchar(max)用于文本信息(nvarchar具有unicode支持)。
varbinary(max) is for binary data (images, files etc). varbinary(max)用于二进制数据(图像,文件等)。
In all cases, it is documented that using MAX
indicates that the maximum storage size is 2^31-1 bytes.
在所有情况下,记录使用
MAX
indicates that the maximum storage size is 2^31-1 bytes.
If it is text data then either varchar(max)
or nvarchar(max)
(supports unicode). 如果是文本数据,则
varchar(max)
或nvarchar(max)
(支持unicode)。 varchar(max) has a maximum storage size of 2^31-1 bytes ( Ref .) varchar(max)的最大存储大小为2 ^ 31-1个字节( 参考 )
If it is binary data then use varbinary(max)
. 如果是二进制数据,则使用
varbinary(max)
。
You would use either nvarchar(max)
, varchar(max)
or varbinary(max)
您可以使用
nvarchar(max)
, varchar(max)
或varbinary(max)
If you insert data greater than the 8KB row limitation the data is moved off-row to another page in a ROW_OVERFLOW_DATA allocation unit. 如果插入大于8KB行限制的数据,则数据将在行外移动到ROW_OVERFLOW_DATA分配单元中的另一个页面。
The following MSDN article explains this process in further detail. 以下MSDN文章更详细地解释了此过程。
I believe the maximum for varchar(max) is 2GB. 我相信varchar(max)的最大值是2GB。
Don't be confused by the "varchar" bit. 不要被“varchar”位混淆。
It basically means you can use most functions on varchar(max)
like you would on varchar(50) or
varchar(1000) or
varchar(8000)`. 它基本上意味着您可以像在varchar(50)
or
varchar(1000) or
varchar(8000)上一样使用varchar(max)
上的大多数函数。
So you can have varchar(50)
or varchar(1000)
upto varchar(8000)
but for storing longer strings you'd use varchar(max)
. 所以你可以让
varchar(50)
或varchar(1000)
达到varchar(8000)
但是为了存储更长的字符串你需要使用varchar(max)
。
The "max" or "50"/"1000"/"8000" bit simply determines internal storage + maximum string length. “max”或“50”/“1000”/“8000”位仅确定内部存储+最大字符串长度。
There a few minor differences, such as indexing, of course. 当然,还有一些细微差别,例如索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.