Ricerca nel sito web

Correggi l'errore MySQL n. 1064: hai un errore nella sintassi SQL... vicino a "TYPE=MyISAM?"


Questo errore si verifica quando utilizziamo TYPE per ENGINE NAME. L'errore è il seguente:

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

Ora, in MySQL 8, puoi utilizzare ENGINE invece di Type. Creiamo innanzitutto una tabella:

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)

Inserisci alcuni record nella tabella utilizzando il comando di inserimento:

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)

Visualizza tutti i record dalla tabella utilizzando l'istruzione select :

mysql> select * from DemoTable1836;

Ciò produrrà il seguente output:

+----------+------------+
| ClientId | ClientName |
+----------+------------+
|        1 | Chris      |
|        2 | David      |
|        3 | Mike       |
|        4 | Sam        |
+----------+------------+
4 rows in set (0.00 sec)

Articoli correlati: