0

有人可以看看下面的脚本并告诉我为什么会出错吗?它来自 db2(通过 Razor SQL),我已经能够纠正所有其他错误,但我无法弄清楚这一点。它进入MYSQL。(最新版本)

CREATE TABLE APCHECKIN (
    CHKBCH_NO INTEGER NOT NULL,
    ENTERDATETIME TIMESTAMP DEFAULT CURRENT TIMESTAMP NOT NULL,
    VENDOR_NO INTEGER DEFAULT 0 NOT NULL,
    INVOICE_NO VARCHAR(18) NOT NULL,
    CHK_NO INTEGER,
    PAIDAMOUNT DECIMAL(14,2) DEFAULT 0 NOT NULL,
    PRIMARY KEY (CHKBCH_NO,ENTERDATETIME,VENDOR_NO,INVOICE_NO)
);

这是我得到的错误。我假设这与我只是忽略它的时间戳有关!

Error : 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 'CURRENT TIMESTAMP NOT NULL,
    VENDOR_NO INTEGER DEFAULT 0 NOT NULL,
    INVOICE_NO V' at line 3

谢谢你的帮助!

4

1 回答 1

2

您需要在CURRENT_TIMESTAMP中使用下划线

CREATE TABLE APCHECKIN (
    CHKBCH_NO INTEGER NOT NULL,
    ENTERDATETIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    VENDOR_NO INTEGER DEFAULT 0 NOT NULL,
    INVOICE_NO VARCHAR(18) NOT NULL,
    CHK_NO INTEGER,
    PAIDAMOUNT DECIMAL(14,2) DEFAULT 0 NOT NULL,
    PRIMARY KEY (CHKBCH_NO,ENTERDATETIME,VENDOR_NO,INVOICE_NO)
);

http://sqlfiddle.com/#!2/92758

于 2012-12-15T22:49:25.357 回答