在DB2中创建表

时间:2015-10-28 14:01:34

标签: sql database db2

我是DB2的新手。我尝试使用以下查询创建表:

CREATE TABLE DB2ADMIN.CERTIFICATE_TAB
(
    CERT_ID                     CHAR(36) NOT NULL,
    CERT_TRS_SEQ_NBR            SMALLINT(5) NOT NULL,
    EFFECTIVE_DT                DATE NOT NULL,
    CERT_EFF_TYPE_CD            CHAR(1) NOT NULL,
    CERT_STATUS_CD              CHAR(1) NOT NULL,
    CERT_VER_NBR                SMALLINT(5),
    EXPIRATION_DT               DATE NOT NULL,
    CERT_NBR                    INTEGER(10),
    CERT_ISSUE_CD               CHAR(1),
    CERT_DTB_CD                 CHAR(1),
    CERT_ERROR_CD               CHAR(10),
    FORM_AS_OF_DT               DATE,
    CERT_RNL_STATUS_CD          CHAR(1),
    CERT_CTU_CNC_IND            CHAR(1),
    CERT_FLD_ISS_IND            CHAR(1),
    CERT_MANUAL_IND             CHAR(1),
    CERT_FLD_ISS_BY_CD          CHAR(1),
    MNL_ADDENDUM_IND            CHAR(1),
    FORM_LEVEL1_CD              CHAR(10),
    FORM_LEVEL2_CD              CHAR(10),
    DOC_ON_FILE_IND             CHAR(1),
    STD_POL_IND                 CHAR(1),
    WET_SIGN_IND                CHAR(1),
    CERT_USER_ID                CHAR(25),
    CERT_ROUTE_PATH_CD          CHAR(10),
    CERT_USER_TXT               VARCHAR(255),
    CERT_ERROR_DES              VARCHAR(2000),
    LAST_MDF_USER_ID            CHAR(25) NOT NULL,
    ISSUE_ACY_TS                TIMESTAMP(26,6),
    LAST_MDF_ACY_TS             TIMESTAMP(26,6) NOT NULL,
    CONSTRAINT SQL120103120640250 PRIMARY KEY (CERT_ID, CERT_TRS_SEQ_NBR),
    CONSTRAINT CMSICER1 UNIQUE (CERT_ID, CERT_TRS_SEQ_NBR)
);

但是我收到了以下错误

错误:DB2 SQL错误:SQLCODE = -104,SQLSTATE = 42601,SQLERRMC = SMALLINT; CERT_TRS_SEQ_NBR; CHARACTER,DRIVER = 3.50.152  SQLState:42601  ErrorCode:-104

有人可以指出我在做什么错误吗?

1 个答案:

答案 0 :(得分:2)

取出所有额外的大小说明符,你没有指定SMALLINT,INTEGER或TIMESTAMP的大小。也使用CHARACTER而不是CHAR

CREATE TABLE DB2ADMIN.CERTIFICATE_TAB
(
    CERT_ID                     CHARACTER(36) NOT NULL,
    CERT_TRS_SEQ_NBR            SMALLINT NOT NULL,
    EFFECTIVE_DT                DATE NOT NULL,
    CERT_EFF_TYPE_CD            CHARACTER(1) NOT NULL,
    CERT_STATUS_CD              CHARACTER(1) NOT NULL,
    CERT_VER_NBR                SMALLINT,
    EXPIRATION_DT               DATE NOT NULL,
   CERT_NBR                    INTEGER,
    CERT_ISSUE_CD               CHARACTER(1),
    CERT_DTB_CD                 CHARACTER(1),
    CERT_ERROR_CD               CHARACTER(10),
    FORM_AS_OF_DT               DATE,
    CERT_RNL_STATUS_CD          CHARACTER(1),
    CERT_CTU_CNC_IND            CHARACTER(1),
    CERT_FLD_ISS_IND            CHARACTER(1),
    CERT_MANUAL_IND             CHARACTER(1),
    CERT_FLD_ISS_BY_CD          CHARACTER(1),
    MNL_ADDENDUM_IND            CHARACTER(1),
    FORM_LEVEL1_CD              CHARACTER(10),
    FORM_LEVEL2_CD              CHARACTER(10),
    DOC_ON_FILE_IND             CHARACTER(1),
    STD_POL_IND                 CHARACTER(1),
    WET_SIGN_IND                CHARACTER(1),
    CERT_USER_ID                CHARACTER(25),
    CERT_ROUTE_PATH_CD          CHARACTER(10),
    CERT_USER_TXT               VARCHAR(255),
    CERT_ERROR_DES              VARCHAR(2000),
    LAST_MDF_USER_ID            CHARACTER(25) NOT NULL,
    ISSUE_ACY_TS                TIMESTAMP,
    LAST_MDF_ACY_TS             TIMESTAMP NOT NULL,
    CONSTRAINT SQL120103120640250 PRIMARY KEY (CERT_ID, CERT_TRS_SEQ_NBR),
    CONSTRAINT CMSICER1 UNIQUE (CERT_ID, CERT_TRS_SEQ_NBR)
);