我想创建一个用数字命名的表。在phpMyAdmin中它完全有可能。但是当我在exec中尝试使用create时,这是不可能的。我试过报价但仍然没有成功。我发现的唯一方法是在前面添加一个alpha。
不工作:
$Integer=1;
$listersDatabase->exec("create table $Integer(row int(15) auto_increment primary key)");
会工作:
$Integer=1;
$listersDatabase->exec("create table T$Integer(row int(15) auto_increment primary key)");
如何创建一个数字表名?谢谢
如果您尝试创建索引表以根据某些ID提高速度,例如 user1_stats,user2_stats,user3_stats ......您错了。 MySQL允许您根据某些ID对表进行分区。 MySQL performance: multiple tables vs. index on single table and partitions
答案 0 :(得分:3)
您是否尝试过添加反引号?
从手册中:标识符可以引用或不引用。如果标识符包含特殊字符或是保留字,则必须在引用时引用它。 (例外:在限定名称中的句点之后的保留字必须是标识符,因此不需要引用。)保留字在第9.3节“关键字和保留字”中列出。
http://dev.mysql.com/doc/refman/5.7/en/identifiers.html
编辑:标识符可以以数字开头,但除非引用可能不仅仅由数字组成。