您可以在MySQL中使用数字作为表名吗? [英] 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中使用数字作为表名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文