MySQL alter table查询的正确语法是什么?

时间:2015-03-07 08:03:17

标签: php mysql

我尝试运行以下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

3 个答案:

答案 0 :(得分:2)

单引号(')表示字符串文字。对象名称(如列)不是字符串 - juts会丢失引号:

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

答案 1 :(得分:2)

尝试将'mark'更改为标记,如下所示:

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

答案 2 :(得分:1)

您只需删除'标记

附近的引号即可
$strSQL3=mysqli_query($connection," alter table mark_list add column mark int(2) " ) or die(mysqli_error($connection));
相关问题