Mysql case sensitive issu
Mysql has the following three topics on case-sensitive topics: 1. Table names and library names linux/unix are case-sensitive, that is, you can create two tables called test and TEST, but windows is case-insensitive by default. LINUX: edit / etc/my.cnf file, add the lower_case_table_names=1 parameter under the [mysqld] section, so it is case-insensitive. You cannot create two tables of test and TEST in one library, and set the corresponding values (Note: case-sensitive when 0 is case-sensitive, case-sensitive when 1 is case-insensitive, that is, case-insensitive, default is 0) 2, the field names of tables are case-insensitive by default under linux, that is, if there is a field called id in a table, you cannot create an ID field. 3. For the contents of the table, the default query is case-insensitive. If you want to distinguish the case of field values when querying, you need to set the BINARY property for the field values, which can be set in a variety of ways: a, set at creation time: CREATE TABLE T (A VARCHAR (10) BINARY); B, modify using alter: ALTER TABLE tablename MODIFY COLUMN cloname VARCHAR (10) BINARY; specific experimental procedure: mysql > create table ll (name varchar Mysql > insert into ll values ('hh'); Query OK, 1 row affected (0.00 sec) mysql > insert into ll values (' hH'); Query OK, 1 row affected (0.00 sec) mysql > select * from ll where name='hh'; +-+ | name | +-+ | hh | hH | +-+ 2 rows in set (0.00 sec) when you add the primary key, you will report an error mysql > alter table ll add primary key (name). ERROR 1062 (23000): Duplicate entry 'hh' for key' PRIMARY' modifies the value of the name column of the table to be case-insensitive. Mysql > alter table ll MODIFY name varchar BINARY; Query OK, 2 rows affected (0.02 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql > select * from ll where name='hh'; +-+ | name | +-+ | hh | +-+ 1 row in set (0.00 sec) and then add the primary key. Mysql > alter table ll add primary key (name); Query OK, 0 rows affected (0.02 sec) Records: 0 Duplicates: 0 Warnings: 0
Summary: MySQL database name, table name, column name, alias case default rules are as follows: 1, database name and table name is strictly case-sensitive; 2, table aliases are strictly case-sensitive; 3, column names and column aliases are case-sensitive in all cases; 4, variable names are strictly case-sensitive; MySQL is not case-sensitive in Windows.