溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

mysql 大小寫敏感 lower_case_table_names

發(fā)布時間:2020-08-04 21:31:30 來源:ITPUB博客 閱讀:133 作者:pxbibm 欄目:MySQL數(shù)據(jù)庫
 在MySQL中,數(shù)據(jù)庫對應(yīng)數(shù)據(jù)目錄中的目錄。數(shù)據(jù)庫中的每個表至少對應(yīng)數(shù)據(jù)庫目錄中的一個文件(也可能是多個,取決于存儲引擎)。因此,所使用操作系統(tǒng)的大小寫敏感性決定了數(shù)據(jù)庫名和表名的大小寫敏感性。
    在大多數(shù)Unix中數(shù)據(jù)庫名和表名對大小寫敏感,而在Windows中對大小寫不敏感。一個顯著的例外情況是Mac OS X,它基于Unix但使用默認(rèn)文件系統(tǒng)類型(HFS+),對大小寫不敏感。然而,Mac OS X也支持UFS卷,該卷對大小寫敏感,就像Unix一樣。
    變量lower_case_file_system說明是否數(shù)據(jù)目錄所在的文件系統(tǒng)對文件名的大小寫敏感。ON說明對文件名的大小寫不敏感,OFF表示敏感。

Mysql官方文檔的介紹:

Value

Meaning

0

Table and database names are stored on disk using the lettercase specified in the CREATE TABLE orCREATE DATABASE statement. Name comparisons are case sensitive. You should not set this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or Mac OS X). If you force this variable to 0 with --lower-case-table-names=0 on a case-insensitive file system and access MyISAM tablenames using different lettercases, index corruption may result.

1

Table names are stored in lowercase on disk and name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.

2

Table and database names are stored on disk using the lettercase specified in the CREATE TABLE orCREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This works only on file systems that are not case sensitive! InnoDB table names are stored in lowercase, as for lower_case_table_names=1.

 

默認(rèn)為0,大小寫敏感。

設(shè)置1,大小寫不敏感。創(chuàng)建的表,數(shù)據(jù)庫都是以小寫形式存放在磁盤上,對于sql語句都是轉(zhuǎn)換為小寫對表和DB進(jìn)行查找。

設(shè)置2,創(chuàng)建的表和DB依據(jù)語句上格式存放,凡是查找都是轉(zhuǎn)換為小寫進(jìn)行。

If you plan to set the lower_case_table_names system variable to 1 on Unix, you must first convert your old database and table names to lowercase before stopping mysqld and restarting it with the new variable setting. To do this for an individual table, use RENAME TABLE:

當(dāng)想設(shè)置lower_case_table_names = 1時,在重啟數(shù)據(jù)庫實(shí)例之前就需要將原來的數(shù)據(jù)庫和表轉(zhuǎn)換為小寫。

官方文檔的解釋。要開啟lower_case_table_names = 1 。先要將大寫字母數(shù)據(jù)庫更改為小寫。否則將找不到數(shù)據(jù)庫名。

 所以要想忽略大小寫,還需要提前將大寫數(shù)據(jù)庫名更改小寫,否則報錯。數(shù)據(jù)庫名無法rename.可以新建一個小寫的數(shù)據(jù)庫名。
然后rename table 到新的數(shù)據(jù)庫,完成表的遷移。
在進(jìn)行數(shù)據(jù)庫參數(shù)設(shè)置之前,需要掌握這個參數(shù)帶來的影響,切不可盲目設(shè)置。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI