解决MySQL错误1064(42000):语法错误?

如果假设您使用的是var_char而不是varchar类型,则会发生此错误。要消除这种类型的错误,请使用例如varchar(100)而不是var_char(100)。

现在让我们看看如何发生此错误-

mysql> create table removeErrorDemo
   -> (
   -> StudentId int,
   -> StudentName var_char(50)
   -> );

以下是显示错误的输出-

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 'var_char(50)
)' at line 4

现在让我们消除错误。这是删除错误1064(42000)的查询-

mysql> create table removeErrorDemo
   -> (
   -> StudentId int,
   -> StudentName varchar(100)
   -> );

上面,我们已经正确设置了varchar,因此不会发生错误。