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

Is MySQL character data case sensitive?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article introduces the knowledge of "is MySQL character data case sensitive?". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

MySQL character data is case sensitive

MySQL is case-insensitive by default when storing values of character types. So if the 'binary' keyword is not specified in select, the default returned value is ignored size.

one

CREATE TABLE `test_ t1` (

two

`ACCOUNT` varchar (100) DEFAULT NULL

three

) ENGINE=InnoDB DEFAULT CHARSET=utf8

1 www.2cto.com

INSERT INTO TEST_T1 VALUES ('MySQL'), ('')

one

Mysql > select * from test_t1 where vr_web_account like'm%'

two

+-+

three

| | VR_WEB_ACCOUNT |

four

+-+

five

| | MySQL |

six

| | mysql |

seven

+-+

eight

2 rows in set (0.08 sec)

After using the 'binary' keyword in the query condition:

one

Mysql > select * from test_t1 where binary vr_web_account like'm%'

two

+-+

three

| | VR_WEB_ACCOUNT |

four

+-+

five

| | mysql |

six

+-+

seven

1 row in set (0.00 sec)

The above is not the focus of this note, this article is mainly about how to modify the character collation of column to achieve the purpose of case sensitivity. MySQL four-tier character set control will not be discussed here.

Www.2cto.com

one

ALTER TABLE `TEST_ T1` MODIFY COLUMN `VR_WEB_ ACCOUNT` varchar (100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL

one

Select * from test_t1 where vr_web_account like'm%'

two

+-+

three

| | VR_WEB_ACCOUNT |

four

+-+

five

| | mysql |

six

+-+

seven

1 row in set (0.00 sec)

This is the end of the content of "MySQL character data is case sensitive?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Database

Wechat

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

12
Report