首页  >  问答  >  正文

有人能找到这个MySQL代码中的错误吗?(初学者)

<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>我正在使用MySQL工作台,我试图创建一个名为学生的表。然而,我的代码给出了错误信息</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>我试图通过移除表来解决这个问题,像这样:</p> <pre class="brush:php;toolbar:false;">CREATE TABLE `students`.`studentinfo` ( ) ENGINE = InnoDB COMMENT = 'test';</pre> <p>即使这样,它仍然不起作用!它给出了相同的错误信息:</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粉469090753P粉469090753453 天前367

全部回复(1)我来回复

  • P粉590428357

    P粉5904283572023-07-25 13:50:11

    Varchar需要一个长度:

    CREATE TABLE `students`.`studentinfo` (
    id int,
    name varchar(100),
    age int
    )

    回复
    0
  • 取消回复