国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > MySQL > 正文

深入淺析MySQL 中 Identifier Case Sensitivity問(wèn)題

2024-07-24 12:49:50
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

在MySQL當(dāng)中,有可能遇到表名大小寫(xiě)敏感的問(wèn)題。其實(shí)這個(gè)跟平臺(tái)(操作系統(tǒng))有關(guān),也跟系統(tǒng)變量lower_case_table_names有關(guān)系。下面總結(jié)一下,有興趣可以查看官方文檔“Identifier Case Sensitivity”

In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory (and possibly more, depending on the storage engine). Triggers also correspond to files. Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database, table, and trigger names. This means such names are not case-sensitive in Windows, but are case-sensitive in most varieties of Unix. One notable exception is macOS, which is Unix-based but uses a default file system type (HFS+) that is not case-sensitive. However, macOS also supports UFS volumes, which are case-sensitive just as on any Unix. See Section 1.8.1, “MySQL Extensions to Standard SQL”. Thelower_case_table_names system variable also affects how the server handles identifier case sensitivity, as described later in this section.

在 MySQL 中, 數(shù)據(jù)庫(kù)對(duì)應(yīng)于數(shù)據(jù)目錄中的目錄。數(shù)據(jù)庫(kù)中的每個(gè)表對(duì)應(yīng)于數(shù)據(jù)庫(kù)目錄中至少一個(gè)文件 (可能更多, 具體取決于存儲(chǔ)引擎)。觸發(fā)器也對(duì)應(yīng)于文件。因此, 底層操作系統(tǒng)的區(qū)分大小寫(xiě)在數(shù)據(jù)庫(kù)、表和觸發(fā)器名稱的大小寫(xiě)敏感度方面起著重要作用。這意味著這些名稱在 Windows 中不區(qū)分大小寫(xiě), 但在大多數(shù)類型的 Unix 中都是區(qū)分大小寫(xiě)的。一個(gè)顯著的例外是 macOS, 它是基于 Unix 的, 但使用的是不區(qū)分大小寫(xiě)的默認(rèn)文件系統(tǒng)類型 (HFS+)。但是, macOS 還支持 UFS 卷, 它們與任何 Unix 一樣都是區(qū)分大小寫(xiě)的。參見(jiàn)1.8.1 節(jié), “MySQL Extensions to Standard SQL“。lower_case_table_names 系統(tǒng)變量還影響服務(wù)器處理標(biāo)識(shí)符大小寫(xiě)靈敏度的方式, 如本節(jié)后面所述。

 Linux系統(tǒng):

數(shù)據(jù)庫(kù)名與表名是嚴(yán)格區(qū)分大小寫(xiě)的;
表的別名是嚴(yán)格區(qū)分大小寫(xiě)的;
列名與列的別名在所有的情況下均是忽略大小寫(xiě)的;
變量名也是嚴(yán)格區(qū)分大小寫(xiě)的;

Windows系統(tǒng):

都不區(qū)分大小寫(xiě)
Mac OS下(非UFS卷):
都不區(qū)分大小寫(xiě)

注意事項(xiàng):列名、索引、存儲(chǔ)過(guò)程、事件名稱在任何平臺(tái)上都不區(qū)分大小寫(xiě),列別名也不區(qū)分大小寫(xiě)。

Notice:Column, index, stored routine, and event names are not case sensitive on any platform, nor are column aliases.

下面在測(cè)試環(huán)境為Red Hat Enterprise Linux Server release 5.7, MySQL 5.6.20:

mysql> show variables like 'lower_case_table_names';+------------------------+-------+| Variable_name | Value |+------------------------+-------+| lower_case_table_names | 0 |+------------------------+-------+1 row in set (0.00 sec)mysql> mysql> use mydb;Database changedmysql> create table test(id int);Query OK, 0 rows affected (0.07 sec)mysql> create table TEST(id int);Query OK, 0 rows affected (0.09 sec)mysql> insert into test values(1);Query OK, 1 row affected (0.03 sec)mysql> insert into TEST value(2);Query OK, 1 row affected (0.00 sec)mysql> select * from test;+------+| id |+------+| 1 |+------+1 row in set (0.00 sec)mysql> select * from TEST;+------+| id |+------+| 2 |+------+1 row in set (0.00 sec)mysql>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 衡山县| 白银市| 铜山县| 临潭县| 河东区| 汾西县| 大姚县| 本溪市| 永川市| 林口县| 西华县| 习水县| 佛教| 铜梁县| 长岭县| 佛冈县| 天水市| 鹤岗市| 桃源县| 太白县| 武邑县| 庆云县| 宁夏| 泸西县| 庄浪县| 乌兰县| 尚志市| 盘锦市| 油尖旺区| 台南县| 樟树市| 泰顺县| 东乡族自治县| 朝阳县| 五台县| 綦江县| 平乐县| 北安市| 法库县| 藁城市| 和田市|