2013年8月19日月曜日

大文字小文字



MySQLではcharとvarcharの、(少なくとも半角英数字の。それ以外は試していません)大文字小文字を


区別してくれないようです。


ただし、「BINARY」属性を付けると大文字小文字を区別してくれます。


マニュアルを読みましょうって話だと思いますが…こういう仕様なんですねぇ…。


「show create table」コマンドを用いるとテーブルの違いが明らかになりますが、


「desc」コマンドでは属性情報までは出ないようです。





例:


C:\xampp\mysql\bin>mysql -u ***** -p ********


Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 4


Server version: 5.1.37 Source distribution


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> use test;


Database changed


mysql>


mysql>


mysql>


mysql> create table test_table_01 (


-> name varchar(10)


-> );


Query OK, 0 rows affected (0.05 sec)


mysql>


mysql> insert into test_table_01 values ('AAA');


Query OK, 1 row affected (0.06 sec)


mysql> insert into test_table_01 values ('aaa');


Query OK, 1 row affected (0.00 sec)


mysql> select * from test_table_01\G;


/*************************** 1. row ***************************


name: AAA


/*************************** 2. row ***************************


name: aaa


2 rows in set (0.00 sec)


ERROR:


No query specified


mysql>


mysql> select * from test_table_01 where name = 'aaa'\G;


/*************************** 1. row ***************************


name: AAA


/*************************** 2. row ***************************


name: aaa


2 rows in set (0.00 sec)


ERROR:


No query specified


mysql>


mysql> select * from test_table_01 where name = 'AAA'\G;


/*************************** 1. row ***************************


name: AAA


/*************************** 2. row ***************************


name: aaa


2 rows in set (0.00 sec)


ERROR:


No query specified


mysql>


mysql>


mysql>


mysql> show create table test_table_01\G;


/*************************** 1. row ***************************


Table: test_table_01


Create Table: CREATE TABLE `test_table_01` (


`name` varchar(10) DEFAULT NULL


) ENGINE=MyISAM DEFAULT CHARSET=latin1


1 row in set (0.00 sec)


ERROR:


No query specified


mysql>


mysql>


mysql> alter table test_table_01 modify name varchar(10) binary;


Query OK, 2 rows affected (0.09 sec)


Records: 2 Duplicates: 0 Warnings: 0


mysql>


mysql> select * from test_table_01 where name = 'aaa'\G;


/*************************** 1. row ***************************


name: aaa


1 row in set (0.02 sec)


ERROR:


No query specified


mysql>


mysql>


mysql> select * from test_table_01 where name = 'AAA'\G;


/*************************** 1. row ***************************


name: AAA


1 row in set (0.00 sec)


ERROR:


No query specified


mysql>


mysql>


mysql> show create table test_table_01\G;


/*************************** 1. row ***************************


Table: test_table_01


Create Table: CREATE TABLE `test_table_01` (


`name` varchar(10) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL


) ENGINE=MyISAM DEFAULT CHARSET=latin1


1 row in set (0.00 sec)


ERROR:


No query specified


mysql>





0 件のコメント:

コメントを投稿