无法执行命令:MySQL

时间:2017-06-11 21:22:32

标签: mysql

create table `payrollmanagementsystem`.DEDUCTION
(
    CODE VARCHAR(50) not null primary key,
    NAME VARCHAR(50),
    SALARYPERDAY DOUBLE PRECISION,
    LEAVE INT,
    KWSP DOUBLE PRECISION,
    TOTALDEDUCTION DOUBLE PRECISION
)

我遇到了无法执行命令的问题,如下所示:

Unable to execute command:
create table `payrollmanagementsystem`.DEDUCTION
(
    CODE VARCHAR(50) not null primary key,
    NAME VARCHAR(50),
    SALARYPERDAY DOUBLE PRECISION,
    LEAVE INT,
    KWSP DOUBLE PRECISION,
    TOTALDEDUCTION DOUBLE PRECISION
)
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 'LEAVE INT,
    KWSP DOUBLE PRECISION,
    TOTALDEDUCTION DOUBLE PRECISION
)' at line 6

2 个答案:

答案 0 :(得分:0)

因此: LEAVE - keyword

答案 1 :(得分:0)

正如其他人所指出的,LEAVE是一个关键词。要解决您的问题,请使用反引号:

`LEAVE` INT,

请注意 CODE 也是关键字,但在这种情况下,它不会导致问题。逃避列名称仍然是一种很好的做法。