有人能找到這個MySQL程式碼中的錯誤嗎?(初學者)
P粉469090753
P粉469090753 2023-07-24 17:17:03
0
1
362
<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粉469090753
P粉469090753

全部回覆(1)
P粉590428357

Varchar需要一個長度:

CREATE TABLE `students`.`studentinfo` (
id int,
name varchar(100),
age int
)
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!