MySQL 哈希值作为列名
使用 PHP 的 md5(microtime())
结果作为列名创建表时,出现语法错误。
特别是,错误被抛出在 ** 周围的部分:
CREATE TABLE form_data_38 (
id INT SIGNED auto_increment NOT NULL,
rltd_pri_key INT SIGNED NULL,
0accc77c084cc74a51dee479f8d095e3 TEXT(65535) NOT NULL,
**092e60b78f7804e86ea9a6e83701a929 TEXT(65535) NOT NULL**,
6734131796201537410e4d43635bf1b3 TEXT(65535) NULL,
PRIMARY KEY (id)
) TYPE=InnoDB;
令我困惑的是为什么它被抛出在那个位置而不是之前的其他 2 个哈希值。我将“a”附加到列名中,它创建的表没有问题。我搜索了 MySQL 命名规则,但到目前为止我还没有想出任何东西。它只是说所有字母数字字符加上“_”和“$”都可以使用,在这种情况下应该没问题。
我缺少什么?
I'm getting a syntax error when creating a table with the result of PHP's md5(microtime())
as the column name.
In particular, the error is getting thrown at the part with ** surrounding it:
CREATE TABLE form_data_38 (
id INT SIGNED auto_increment NOT NULL,
rltd_pri_key INT SIGNED NULL,
0accc77c084cc74a51dee479f8d095e3 TEXT(65535) NOT NULL,
**092e60b78f7804e86ea9a6e83701a929 TEXT(65535) NOT NULL**,
6734131796201537410e4d43635bf1b3 TEXT(65535) NULL,
PRIMARY KEY (id)
) TYPE=InnoDB;
What is confusing me is why it's being thrown at that spot and not the other 2 hash values prior to it. I appended 'a' to the column names and it created the table no problem. I've searched MySQL naming rules and so far I haven't come up with anything. It just says all alphanumeric characters plus '_' and '$' are okay to use, which should be fine in this instance.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将表和字段名称放在反引号中:
`09e4_fieldName`
,至少对于那些可能产生此类问题的人来说:Put your table and field names in backquotes:
`09e4_fieldName`
, at least for those that can create such problems: