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 中使用数字作为表名吗?


基础教程推荐
- Sql Server 字符串到日期的转换 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01