Tuesday 2 August 2016

LENGTH: Estimates the space that occupied in memory.



LENGTH(string): Return the memory occupiedby string in . It estimates the space that occupied in memory.

mysql> SELECT LENGTH("Hello");
+-----------------+
| LENGTH("Hello") |
+-----------------+
|               5 |
+-----------------+
1 row in set (0.01 sec)

mysql>
mysql> SELECT LENGTH("你好");
+------------------+
| LENGTH("你好")   |
+------------------+
|                6 |
+------------------+
1 row in set (0.00 sec)


Remember LENGTH function don’t return the characters in the string, it return the space occupied in bytes. To get number of characters use CHAR_LENGTH function.


Previous                                                 Next                                                 Home

No comments:

Post a Comment