SQL varchar(-1) 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1713093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does varchar(-1) mean?
提问by Sreejith S T
What is the meaning of varchar(-1) in SQL Server 2008? Is it an alternative for varchar(max)?
SQL Server 2008 中 varchar(-1) 的含义是什么?它是 varchar(max) 的替代品吗?
回答by gbn
It's how to represent varchar(max) in .net SQLDBType(not explicitly stated, but length is -1)
这是如何在.net SQLDBType 中表示varchar(max)(未明确说明,但长度为-1)
I can't try it in SQL language in SQL Server right now for interest's sake: but I'm sure it's only for client code because varchar is normally strongly defined between 1 and 8000, but for max type it's not.
出于兴趣,我现在不能在 SQL Server 的 SQL 语言中尝试它:但我确定它仅用于客户端代码,因为 varchar 通常在 1 到 8000 之间进行强定义,但对于 max 类型则不然。
回答by Andrew Keith
i think it is varchar(max). I never seen it before.
我认为它是varchar(max)。我以前从未见过。
回答by Srini
It is only SQL Query Analyser which displays -1 instead of Max. In design view, still you can see it as Max.
只有 SQL 查询分析器显示 -1 而不是 Max。在设计视图中,您仍然可以将其视为 Max。
回答by i_am_jorf
The documentationsays:
该文件说:
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.
varchar [ ( n | max ) ] 可变长度的非 Unicode 字符数据。n 可以是 1 到 8,000 之间的值。max 表示最大存储大小为 2^31-1 字节。
So -1 isn't technically valid. It might work, but I wouldn't use it if I were you.
所以 -1 在技术上是无效的。它可能有用,但如果我是你,我不会使用它。
回答by Gabriel Simas
Yes man... it′s a varchar(MAX)
是的,伙计...它是一个 varchar(MAX)