Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the LENGTH () function in MySQL

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use the LENGTH () function in MySQL. It is very detailed and has a certain reference value. Friends who are interested must finish it!

LENGTH ()

The LENGTH (str) and OCTET_LENGTH (str) functions return the byte length of a string, for example:

SELECT LENGTH ('MySQL string function') AS len1, OCTET_LENGTH ('MySQL string function') AS len2;len1 | len2 |-- +-+ 20 | 20 |

In utf8mb4 coding, a Chinese character occupies 3 bytes.

In addition, the CHAR_LENGTH (str) and CHARACTER_LENGTH (str) functions are used to return the character length of the string, that is, the number of characters. For example:

SELECT CHAR_LENGTH ('MySQL string function') AS len1, CHARACTER_LENGTH ('MySQL string function') AS len2;len1 | len2 |-- +-+ 10 | 10 |

The BIT_LENGTH (str) function returns the bit length (number of bits) of a string, for example:

SELECT BIT_LENGTH ('MySQL string function') AS len;len |-+ 160 |

A byte contains 8 bits.

These are all the contents of the article "how to use the LENGTH () function in MySQL". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report