By default, MYSQL queries are case-insensitive.

Source: Internet
Author: User
Tags mysql create mysql insert mysql create table
MYSQL queries are case-insensitive by default, for example, mysqlcreatetablet1 (

MYSQL queries are case-insensitive by default, for example: mysql create table t1 (-name varchar (10); Query OK, 0 rows affected (0.09 sec) mysql insert into t1 values ('you'), ('you'), ('you'); Query OK, 3 rows affected (0.05 sec) Records: 3 Duplicates: 0

MYSQL queries are case-insensitive by default, for example, mysql> create table t1 (-> name varchar (10); Query OK, 0 rows affected (0.09 sec) mysql> insert into t1 values ('you'), ('you'), ('you'); Query OK, 3 rows affected (0.05 sec) Records: 3 Duplicates: 0 Warnings: 0 For this table, the results of the following two queries are the same by default:
Mysql> select * from t1 where name = 'you '; + ------ + | name | + ------ + | you | You | YOU | + ------ + 3 rows in set (0.00 sec) mysql> select * from t1 where name = 'you '; + ------ + | name | + ------ + | you | You | YOU | + ------ + 3 rows in set (0.00 sec)
If you want MYSQL to know whether the letters you entered are in upper or lower case, modify the table:
mysql> alter table t1 change name name varchar(10) binary;Query OK, 3 rows affected (0.20 sec)Records: 3 Duplicates: 0 Warnings: 0mysql> select * from t1 where name = 'you';+------+| name |+------+| you |+------+1 row in set (0.00 sec)mysql> select * from t1 where name = 'YOU';+------+| name |+------+| YOU |+------+1 row in set (0.00 sec)
If YOU just want to implement it in an SQL statement: mysql> select * from t1 where name = binary 'you '; + ------ + | name | + ------ + | YOU | + ------ + 1 row in set (0.02 sec) mysql> select * from t1 where name = binary 'you '; + ------ + | name | + ------ + | you | + ------ + 1 row in set (0.00 sec)
 
If you don't want to be so troublesome and want to make the service case consistent when it is enabled: you can modify my. ini or my. cnf [mysqld] lower_case_table_names = 1 (0: Yes; 1: No) and then restart the MYSQL service. Mysql> show variables like '% case_table % '; + rows + ------- + | Variable_name | Value | + ------------------------ + ------- + | lower_case_table_names | 1 | + rows + ------- + 1 row in set (0.00 sec) Note: WINDOWS systems do not need to be modified, the default value is 1. in LINUX, the default value is 0. Because LINUX scripts are case sensitive.

Original article address: MYSQL queries are case-insensitive by default. Thanks to the original author for sharing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.