mysql 不區分大小寫(大小寫不敏感),mysql區分大小寫

來源:互聯網
上載者:User

mysql 不區分大小寫(大小寫不敏感),mysql區分大小寫

下邊用一張表來區分mysql在windows和linux預設情況下對大小寫敏感程度

作業系統
表名
變數名
欄位值
windows
不敏感
不敏感
不敏感
linux
敏感
敏感
敏感


linux下先不做介紹,因為沒有實際用過,下邊說下在windows下的修改方法:

表名區分大小寫改法:

lower_case_table_names = 0  
其中 0:區分大小寫,1:不區分大小寫


欄位值的改法:

1、 建立時設定: CREATE TABLE T(
        A VARCHAR(10) BINARY  );  
2、 使用alter修改:
        ALTER TABLE `tablename` MODIFY COLUMN `cloname` VARCHAR(45) BINARY; 

3、使用資料庫管理工具改

        注意事項:不能通過直接改table的Collection為bin(如果資料庫字元編碼屬性為utf-8則為utf8_bin)來使所有欄位都生效,必須一個欄位一個欄位的改


mysql 為何設計成不區分大小寫

是否區分大小寫和校對規則有關,預設設的規則是大小寫不敏感的。
說實話 這個問題和回答很玄乎
 
mysql 欄位值不區分大小寫

這未必是mysql的原因,單純的在mysql中查詢是否不區分字元大小寫。

如果你想穩妥點,查詢時可以通過 upper 或是 lower 對字元進行大小寫轉換。
 

相關文章

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.