表创建脚本DB2到MYSQL

时间:2012-12-15 22:46:36

标签: mysql sql

有人可以看看下面的脚本并告诉我为什么会出错吗?它来自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

感谢您的帮助!

1 个答案:

答案 0 :(得分: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