簡體   English   中英

MySQL alter table查詢的正確語法是什么?

[英]what is the correct syntax for MySQL alter table query?

當我嘗試運行以下mysqli調用時

$strSQL3=mysqli_query($connection," alter table mark_list add column 'mark' int(2) " ) or die(mysqli_error($connection));

返回錯誤

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 `mark int(2)` at line 1

單引號( ' )表示字符串文字。 對象名稱(例如列)不是字符串-突出號將引起引號:

$strSQL3 = mysqli_query($connection ,"alter table mark_list add column mark int(2)" ) or die(mysqli_error($connection));

嘗試更改“標記”以這樣標記

    $strSQL3=mysqli_query($connection,
             " alter table mark_list add column mark int(2) " ) 
              or die(mysqli_error($connection));

只需刪除'標記附近的引號

$strSQL3=mysqli_query($connection," alter table mark_list add column mark int(2) " ) or die(mysqli_error($connection));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM