Syntax error MySQL query to fetch column length declared with BLOB type

MySQL query to fetch column length declared with BLOB type



For this, use the LENGTH() function from MySQL. Let us first create a table. We have declared the type of column as BLOB −

mysql> create table DemoTable
(
   Title blob
);
Query OK, 0 rows affected (0.57 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable values('This is a MySQL tutorial');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values('Java is an object oriented programming language');
Query OK, 1 row affected (0.61 sec)
mysql> insert into DemoTable values('C is a procedural language');
Query OK, 1 row affected (0.20 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output −

+-------------------------------------------------+
| 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)

Following is the query to fetch column length declared with BLOB type using the LENGTH() method −

mysql> select length(Title) from DemoTable;

This will produce the following output −

+---------------+
| length(Title) |
+---------------+
|            24 |
|            47 |
|            26 |
+---------------+
3 rows in set (0.00 sec)
Updated on: 2019-10-03T07:16:58+05:30

357 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements