如何建立命名為 a^b 的表,同時具有相同的列名稱?\n名稱?
要建立具有此類名稱的表,我們必須使用引號字元。引號可以是單引號,也可以是雙引號,具體取決於 ANSI_QUOTES SQL 模式。
如果此模式已停用,則識別符號引號字元是反引號(“`”)。考慮以下示例,我們在其中建立了一個名為“select”的表 −
mysql> Create table `a^b`(`a^b` int);
Query OK, 0 rows affected (0.19 sec)
mysql> Create table "a^g"("a^g" int);
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '"a^g" ("a^g" int)' at line 1如果此模式已啟用,那麼我們可以將反引號 (“`”) 和雙引號 (“”) 同時用作引號字元。考慮以下示例,我們在其中建立了與上述名稱類似的表,在啟用此模式後藉助兩個引號字元 −
mysql> Set sql_mode = 'ANSI_Quotes';
Query OK, 0 rows affected (0.03 sec)
mysql> Create table "a^d"("a^d" int);
Query OK, 0 rows affected (0.21 sec)
mysql> Create table `a^e`(`a^e` int);
Query OK, 0 rows affected (0.14 sec)
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP