The content in the MySQL DATA table is case-sensitive.

Source: Internet
Author: User

The content in the MySQL DATA table is case-sensitive.
By default, MYSQL queries are case-insensitive, for example :?

1234567 mysql>createtable t1( ->namevarchar(10));Query OK, 0 rowsaffected (0.09 sec)  mysql>insertinto t1 values('you'),('You'),('YOU');Query OK, 3 rowsaffected (0.05 sec) Records: 3 Duplicates: 0 Warnings: 0

 

For this table, the results of the following two queries are the same by default :?
12345678910111213141516171819 mysql>select* fromt1 wherename = 'you';+------+|name| +------+| you | | You | | YOU | +------+3rowsin set (0.00 sec)  mysql>select* fromt1 wherename = 'YOU';+------+|name| +------+| you | | You | | YOU | +------+3rowsin set (0.00 sec)

 

If you want MYSQL to know whether the letters you entered are in upper or lower case, modify the table :?
1234567891011121314151617181920 mysql>altertable t1 change namename varchar(10)binary;Query OK, 3 rowsaffected (0.20 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql>select* fromt1 wherename = 'you';+------+|name| +------+| you | +------+1 row inset (0.00 sec)  mysql>select* fromt1 wherename = 'YOU';+------+|name| +------+| YOU | +------+1 row inset (0.00 sec)

 

If you just want to implement it in an SQL statement :?
123456789101112131415 mysql>select* fromt1 wherename = binary'YOU';+------+|name| +------+| YOU | +------+1 row inset (0.02 sec)  mysql>select* fromt1 wherename = binary'you';+------+|name| +------+| you | +------+1 row inset (0.00 sec)

 

If you don't want to be so troublesome and want to make the service case consistent when it is enabled: Can you modify my. ini or my. cnf?
123 [mysqld]lower_case_table_names=1(0: Yes; 1: No)

 

Then restart the MYSQL service. ?
1234567 mysql> show variables like'%case_table%';+------------------------+-------+| Variable_name | Value | +------------------------+-------+| lower_case_table_names | 1 | +------------------------+-------+1 row inset (0.00 sec)

Related Article

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.