修复 MySQL 错误 #1064 - 您在 SQL 语法中有错误…在“TYPE=MyISAM 附近
在使用类型作为引擎名称时,会出现此错误。错误如下 −
mysql> create table DemoTable1836 ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(20) )Type=MyISAM AUTO_INCREMENT=1; 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 'Type=MyISAM AUTO_INCREMENT=1' at line 5
现在,在 MySQL 8 中,您可以使用 ENGINE 而非 Type。我们先创建一张表 −
mysql> create table DemoTable1836 ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(20) )ENGINE=MyISAM AUTO_INCREMENT=1; Query OK, 0 rows affected (0.00 sec)
使用 insert 命令在表中插入一些记录 −
mysql> insert into DemoTable1836(ClientName) values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1836(ClientName) values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1836(ClientName) values('Mike'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1836(ClientName) values('Sam'); Query OK, 1 row affected (0.00 sec)
使用 select 语句显示表中的所有记录 −
mysql> select * from DemoTable1836;
这将产生以下输出 −
+----------+------------+ | ClientId | ClientName | +----------+------------+ | 1 | Chris | | 2 | David | | 3 | Mike | | 4 | Sam | +----------+------------+ 4 rows in set (0.00 sec)
广告