MySQL 中表名的最大長度是多少?


根據 MySQL 8.0.12 版本的資訊,表名的最大長度為 64 個字元。

檢視你安裝的 MySQL 版本。

mysql> select version();

以下是輸出:

+-----------+
| version() |
+-----------+
| 8.0.12    |
+-----------+
1 row in set (0.03 sec)

我們可以在建立表時查看錶名的最大長度。如果長度超過 64 個字元,它將不會建立表,並且會丟擲錯誤。

建立了一個表的表名長度超過了 64 個字元。

mysql> create table tableNameDemotableableNameDemotableableNameDemotableableNameDemotable
   -> (
   -> id int
   -> );
ERROR 1059 (42000): Identifier name 'tableNameDemotableableNameDemotableableNameDemotableableNameDemotable' is too long

以上,我們收到一個錯誤,表明識別符號名 (yourTableName) 太長。

檢查如果表名長度為 64 個字元以下是否能執行 −

mysql> create table Demo
   -> (
   -> id int
   -> );
Query OK, 0 rows affected (0.46 sec)

是的,小於 64 個字元的表名可以正常執行。

更新於: 2019 年 7 月 30 日

2K+ 次瀏覽

開啟您的 職業

完成課程獲得認證

開始
廣告