Home > Database > Mysql Tutorial > SQL中DATALENGTH 用法_MySQL

SQL中DATALENGTH 用法_MySQL

WBOY
Release: 2016-06-01 14:05:24
Original
1564 people have browsed it

返回任何表达式所占用的字节数。

语法
DATALENGTH ( expression )

参数
expression

任何类型的表达式。

返回类型
int

注释
DATALENGTH 对 varchar、varbinary、text、image、nvarchar 和 ntext 数据类型特别有用,因为这些数据类型可以存储
可变长度数据。

NULL 的 DATALENGTH 的结果是 NULL。



说明 兼容级别可能影响返回值。有关兼容级别的更多信息,请参见 sp_dbcmptlevel。


示例
此示例查找 publishers 表中 pub_name 列的长度。

USE pubs
GO
SELECT length = DATALENGTH(pub_name), pub_name
FROM publishers
ORDER BY pub_name
GO

下面是结果集:

length pub_name
----------- ----------------------------------------
20 Algodata Infosystems
16 Binnet & Hardley
21 Five Lakes Publishing
5 GGG&G
18 Lucerne Publishing
14 New Moon Books
17 Ramona Publishers
14 Scootney Books

(8 row(s) affected)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template