gpt4 book ai didi

mysql - 当标识符不是保留字或带有空格时,为什么我必须使用 BACKTICKS?

转载 作者:行者123 更新时间:2023-11-29 01:26:44 24 4
gpt4 key购买 nike

反引号没有错误。

DB [XXX]> create temporary table `123456e6` (`id` char (8));
Query OK, 0 rows affected (0.03 sec)

不使用反引号时出错。

DB [XXX]> create temporary table 123451e6 (`id` char (8));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '123451e6 (`id` char (8))' at line 1

我的标识符 123451e6 根据页面 here 是有效的,并且不是保留字或空格或包含任何特殊字符。

最佳答案

您遇到了“仅限数字”规则的微妙情况:

Identifiers may begin with a digit but unless quoted may not consist solely of digits.

e 字符用于数字的科学记数法,MySQL 将 123451e6 解释为“123451 * 106”或 123451000000。除了“e”之外的任何其他字母都会使字符串遵守“仅数字”规则并且可以不加引号使用。例如:

MariaDB [db]> create temporary table 123451f6 (`id` char (8));
Query OK, 0 rows affected (0.02 sec)

关于mysql - 当标识符不是保留字或带有空格时,为什么我必须使用 BACKTICKS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41907836/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com