TEXT数据类型长度 [英] TEXT datatype length

查看:184
本文介绍了TEXT数据类型长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个包含数据类型文本列的表。



Hi,
I created a table which has a column of datatype text.

CREATE TABLE TABTEXT
(
    EMail TEXT
)





但是当我使用sp_help检查这个字段的长度时,它显示该字段的长度为16.



Column_name       输入        Computed          长度

--------------       ------      -----------        ------------

EMail                      text              no                      16





有谁可以告诉我 16 是什么?

推荐答案

CREATE TABLE TABTEXT
(
    EMail TEXT
)

Insert into TABTEXT 
Select 'a'

Select COL_LENGTH('TABTEXT','EMail') as ColumnLength
Select EMail,Datalength(EMail) as DataLength From TABTEXT 



sp_help 中如果你给一个tableName ...在列对象上返回的附加结果集

长度无效,但以字节为单位的列长度 ...



Col_Length:返回列的定义长度(以字节为单位)。您获得的16只是TABTEXT表中字节中的电子邮件列的列长度,默认情况下,它将文本列的长度设置为16 ...如果您在该列中输入一些数据,则可以检查长度使用DataLength的字节...如果要检查字符长度,可以将变量声明为varchar或nvarchar,并将列值赋给该变量,并对该变量使用len ..



上述查询的输出是


In sp_help if you give a tableName...Additional result set returned on column objects
and Length is Nothing but the column length given in Bytes...

Col_Length:Returns the defined length, in bytes, of a column.The 16 what you are getting is nothing but column length of EMail column in Bytes in that TABTEXT table, by Default it takes the length of text column as 16... If you enter a some data into that column u can check the length in bytes by using DataLength... if you want to check the length in characters u can declare a variable as varchar or nvarchar and assign the column value to that variable and use len on that variable..

The output for the above queries is

ColumnLength
------------
  16

EMail	DataLength
-----   ----------
 a	 1





希望这回答你的问题....

查看此链接 http:// msdn.microsoft.com/en-us/library/ms187335.aspx [ sp_help ]

http://msdn.microsoft.com/en-us/library/ms188732。

http://msdn.microsoft.com/en-us/library/ms173486.aspx



Hope this Answers your Question....
Check this links http://msdn.microsoft.com/en-us/library/ms187335.aspx[sp_help]
http://msdn.microsoft.com/en-us/library/ms188732.
http://msdn.microsoft.com/en-us/library/ms173486.aspx


16是默认的最小建议值。

请参阅更多 [ ^ ]
16 is the default minimum recommended value.
Please see more[^]


这篇关于TEXT数据类型长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆