当我尝试执行以下声明时。
create table user_schemas (user_id varchar(255) not null, schemas varchar(255));
我收到了以下错误。
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'schemas varchar(255))' at line 1
当我更改列名称" schemas"对其他事情,它工作正常。
mysql> create table user_schemas (user_id varchar(255) not null, schemas varchar(255));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'schemas varchar(255))' at line 1
mysql>
mysql> create table user_schemas (user_id varchar(255) not null, rules varchar(255));
Query OK, 0 rows affected (0.01 sec)
关于如何解决这个问题的任何想法??
答案 0 :(得分:0)
如果要在SQL语法中使用保留字,则必须使用Backticks (`),如:
create table user_schemas (
user_id varchar(255) not null,
`schemas` varchar(255)
);