Find size of text stored in a specific MySQL column?

MySQLMySQLi Database

You can use length() from MySQL to find the size of text stores in a specific column. Let us first create a table

mysql> create table DemoTable
   (
   CustomerName longtext
   );
Query OK, 0 rows affected (0.67 sec)

Insert records in the table using insert command −

mysql> insert into DemoTable values('Robert');
Query OK, 1 row affected (0.14 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output−

+--------------+
| CustomerName |
+--------------+
| Robert       |
+--------------+
1 row in set (0.00 sec)

Here is the query to find the size of text stored in a specific column −

mysql> select length(CustomerName) from DemoTable;

This will produce the following output displaying the size of text −

+----------------------+
| length(CustomerName) |
+----------------------+
| 6                    |
+----------------------+
1 row in set (0.01 sec)
raja
Published on 03-May-2019 07:43:19
Advertisements