Are you allowed to use numbers as table names in MySQL?(你可以在 MySQL 中使用数字作为表名吗?)
问题描述
我正在考虑有一个程序可以根据需要动态创建新表.我可以在 MySQL 中使用仅用数字命名的表吗?
I'm thinking of having a program that dynamically creates new tables as the need arises. Can I have tables named with just numbers in MySQL?
推荐答案
对象命名规则,包括 MySql 中的表:
Rules for naming objects, including tables in MySql:
http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
标识符可以以数字开头,但除非引用可能不完全由数字.
Identifiers may begin with a digit but unless quoted may not consist solely of digits.
所以这将是无效的:
SELECT * FROM 12345;
但以下内容是有效的:
SELECT * FROM `12345`;
或者,如果在 ANSI 模式下运行,以下将起作用:
Or if running in ANSI mode the following would work:
SET @@session.sql_mode=ANSI_QUOTES;
SELECT * FROM "12345";
这篇关于你可以在 MySQL 中使用数字作为表名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:你可以在 MySQL 中使用数字作为表名吗?


- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- SQL 临时表问题 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01