MySQL查询获取用BLOB类型声明的列长度
为此,请使用LENGTH()
MySQL中的函数。让我们首先创建一个表。我们已经将列的类型声明为BLOB-
mysql> create table DemoTable ( Title blob );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('This is a MySQL tutorial'); mysql> insert into DemoTable values('Java is an object oriented programming language'); mysql> insert into DemoTable values('C is a procedural language');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+-------------------------------------------------+ | Title | +-------------------------------------------------+ | This is a MySQL tutorial | | Java is an object oriented programming language | | C is a procedural language | +-------------------------------------------------+ 3 rows in set (0.00 sec)
以下是使用LENGTH()
方法获取使用BLOB类型声明的列长度的查询-
mysql> select length(Title) from DemoTable;
这将产生以下输出-
+---------------+ | length(Title) | +---------------+ | 24 | | 47 | | 26 | +---------------+ 3 rows in set (0.00 sec)