Can anyone find the error in this MySQL code? (Beginner)
P粉469090753
P粉469090753 2023-07-24 17:17:03
0
1
361
<p><br /></p> <pre class="brush:php;toolbar:false;">CREATE TABLE `students`.`studentinfo` ( id int, name varchar, age int ); ENGINE=InnoDB COMMENT = 'test';</pre> <p>I'm using MySQL workbench and I'm trying to create a table called students. However, my code gives the error message </p> <pre class="brush:php;toolbar:false;">Operation failed: There was an error while applying the SQL script to the database. Executing: CREATE TABLE `students`.`studentinfo` ( id int, name varchar, age int ); ENGINE=InnoDB COMMENT = 'test'; ERROR 1064: 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 ', age int )' at line 3 SQL Statement: CREATE TABLE `students`.`studentinfo` ( id int, name varchar, age int )</pre> <p>I tried to solve the problem by removing the table, like this:</p> <pre class="brush:php;toolbar:false;">CREATE TABLE `students`.`studentinfo` ( ) ENGINE=InnoDB COMMENT = 'test';</pre> <p>Even then, it still doesn't work! It gives the same error message:</p> <pre class="brush:php;toolbar:false;">Operation failed: There was an error while applying the SQL script to the database. Executing: CREATE TABLE `students`.`studentinfo` ( ) ENGINE=InnoDB COMMENT = 'test'; ERROR 1064: 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 ') ENGINE=InnoDB COMMENT = 'test'' at line 2 SQL Statement: CREATE TABLE `students`.`studentinfo` ( ) ENGINE=InnoDB COMMENT = 'test'</pre> <p><br /></p>
P粉469090753
P粉469090753

reply all(1)
P粉590428357

Varchar requires a length:

CREATE TABLE `students`.`studentinfo` (
id int,
name varchar(100),
age int
)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!