/**Begin  **/
    IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DECOMPOSE_TASK')
CREATE TABLE T_EB_DECOMPOSE_TASK
(
    FID               BIGINT          DEFAULT 0   NOT NULL,
    FENTITY           BIGINT          DEFAULT 0   NOT NULL,
    FEXPLAIN          NVARCHAR(255)   DEFAULT ' ' NOT NULL,
    FSRCDIMENSIONJSON NVARCHAR(2000)  DEFAULT ' ' NOT NULL,
    FDECDIMENSIONJSON NVARCHAR(2000)  DEFAULT ' ' NOT NULL,
    FSCHEME           BIGINT          DEFAULT 0   NOT NULL,
    FSTATUS           INT             DEFAULT 0   NOT NULL,
    FVALUE            DECIMAL(23, 10) DEFAULT 0   NOT NULL,
    FHASHCODE         BIGINT          DEFAULT 0   NOT NULL,
    FCREATEDATE       DATETIME,
    FMODIFYDATE       DATETIME,
    FMODIFIER         BIGINT          DEFAULT 0   NOT NULL,
    FCREATER          BIGINT          DEFAULT 0   NOT NULL
);
EXEC P_ALTERPK 'PK_T_EB_DECOMPOSE_TASK', 'T_EB_DECOMPOSE_TASK', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_DECOMPOSE_TASK')
CREATE INDEX IDX_EB_DECOMPOSE_TASK ON T_EB_DECOMPOSE_TASK (FSCHEME ASC, FENTITY ASC);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DECOMPOSE_LOG')
CREATE TABLE T_EB_DECOMPOSE_LOG
(
    FID               BIGINT          DEFAULT 0   NOT NULL,
    FDIMENSION        NVARCHAR(50)    DEFAULT ' ' NOT NULL,
    FDIMMEMBER        NVARCHAR(50)    DEFAULT ' ' NOT NULL,
    FSRCDIMENSIONJSON NVARCHAR(2000)  DEFAULT ' ' NOT NULL,
    FTASK             BIGINT          DEFAULT 0   NOT NULL,
    FSTATUS           INT             DEFAULT 0   NOT NULL,
    FPARENT           BIGINT          DEFAULT 0   NOT NULL,
    FPID              BIGINT          DEFAULT 0   NOT NULL,
    FISSUEFLAG        CHAR(1)         DEFAULT ' ' NOT NULL,
    FSUBMITFLAG       CHAR(1)         DEFAULT ' ' NOT NULL,
    FVALUE            DECIMAL(23, 10) DEFAULT 0   NOT NULL
);
EXEC P_ALTERPK 'PK_T_EB_DECOMPOSE_LOG', 'T_EB_DECOMPOSE_LOG', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_DECOMPOSE_LOG')
CREATE INDEX IDX_EB_DECOMPOSE_LOG ON T_EB_DECOMPOSE_LOG (FTASK ASC);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_TARGETSCHEME')
CREATE TABLE T_EB_TARGETSCHEME
(
    FID               BIGINT         NOT NULL DEFAULT 0,
    FNUMBER           NVARCHAR(80)   NOT NULL DEFAULT ' ',
    FBIZCTRLID        BIGINT         NOT NULL DEFAULT 0,
    FBIZMODELID       BIGINT         NOT NULL DEFAULT 0,
    FCREATOR          BIGINT         NOT NULL DEFAULT 0,
    FCREATEDATE       DATETIME,
    FMODIFIER         BIGINT         NOT NULL DEFAULT 0,
    FMODIFYDATE       DATETIME,
    FMODELID          BIGINT         NOT NULL DEFAULT 0,
    FDATATYPE         BIGINT         NOT NULL DEFAULT 0,
    FVERSION          BIGINT         NOT NULL DEFAULT 0,
    FAUDITTRAIL       BIGINT         NOT NULL DEFAULT 0,
    FCHANGETYPE       NVARCHAR(2000) NOT NULL DEFAULT ' ',
    FCHANGETYPETEXT   NVARCHAR(2000) NOT NULL DEFAULT ' ',
    FCURRENCY         BIGINT         NOT NULL DEFAULT 0,
    FBUDGETPERIOD     NVARCHAR(2000) NOT NULL DEFAULT ' ',
    FBUDGETPERIODTEXT NVARCHAR(2000) NOT NULL DEFAULT ' ',
    FACCOUNT          NVARCHAR(2000) NOT NULL DEFAULT ' ',
    FACCOUNTTEXT      NVARCHAR(2000) NOT NULL DEFAULT ' '
);
EXEC P_ALTERPK 'PK_T_EB_TARGETSCHEME', 'T_EB_TARGETSCHEME', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_TARGETSCHEME_MODEL')
CREATE INDEX IDX_EB_TARGETSCHEME_MODEL ON T_EB_TARGETSCHEME (FMODELID ASC);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_TARGETSCHEME_L')
CREATE TABLE T_EB_TARGETSCHEME_L
(
    FID       BIGINT        NOT NULL DEFAULT 0,
    FPKID     NVARCHAR(36)  NOT NULL DEFAULT ' ',
    FLOCALEID NVARCHAR(10)  NOT NULL DEFAULT ' ',
    FNAME     NVARCHAR(100) NOT NULL DEFAULT ' '
);
EXEC P_ALTERPK 'PK_T_EB_TARGETSCHEME_L', 'T_EB_TARGETSCHEME_L', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_TARGETSCHEME_L_NAME')
CREATE INDEX IDX_EB_TARGETSCHEME_L_NAME ON T_EB_TARGETSCHEME_L (FNAME ASC);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_TARGETSCHEME_RECORD')
CREATE TABLE T_EB_TARGETSCHEME_RECORD
(
    FID             BIGINT         NOT NULL DEFAULT 0,
    FNUMBER         NVARCHAR(100)  NOT NULL DEFAULT ' ',
    FBIZCTRL        BIGINT         NOT NULL DEFAULT 0,
    FDATATYPE       BIGINT         NOT NULL DEFAULT 0,
    FVERSION        BIGINT         NOT NULL DEFAULT 0,
    FAUDITTRAIL     BIGINT         NOT NULL DEFAULT 0,
    FENTITY         NVARCHAR(2000) NOT NULL DEFAULT ' ',
    FDESC           NVARCHAR(255)  NOT NULL DEFAULT ' ',
    FCREATOR        BIGINT         NOT NULL DEFAULT 0,
    FCREATEDATE     DATETIME,
    FMODIFIER       BIGINT         NOT NULL DEFAULT 0,
    FMODIFYDATE     DATETIME,
    FMODELID        BIGINT         NOT NULL DEFAULT 0,
    FSTATUS         CHAR(1)                 DEFAULT 'A' NOT NULL,
    FTARGETSCHEMEID BIGINT         NOT NULL DEFAULT 0
);
EXEC P_ALTERPK 'PK_T_EB_TARGETSCHEME_RECORD', 'T_EB_TARGETSCHEME_RECORD', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_TARGETSCHEME_RE_NUMBER')
CREATE INDEX IDX_EB_TARGETSCHEME_RE_NUMBER ON T_EB_TARGETSCHEME_RECORD (FNUMBER ASC);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_TARGET_DIMMAPPER')
CREATE TABLE T_EB_TARGET_DIMMAPPER
(
    FID           BIGINT       DEFAULT 0   NOT NULL,
    FNUMBER       NVARCHAR(80) DEFAULT ' ' NOT NULL,
    FSTATUS       NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FCREATORID    BIGINT,
    FMODIFIERID   BIGINT,
    FENABLE       NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FCREATETIME   DATETIME,
    FMODIFYTIME   DATETIME,
    FMASTERID     BIGINT,
    FSCRBIZCTRLID BIGINT,
    FTARBIZCTRLID BIGINT,
    FDIMNUMBER    NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FUSESTATUS    CHAR(1)      DEFAULT '1' NOT NULL,
    FDIMNAME      NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FMODEL        BIGINT
);
EXEC P_ALTERPK 'PK_T_EB_TARGET_DIMMAPPER', 'T_EB_TARGET_DIMMAPPER', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_TARGET_DIMMAPPER_MODEL')
CREATE INDEX IDX_T_EB_TARGET_DIMMAPPER_MODEL ON T_EB_TARGET_DIMMAPPER (FMODEL);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_TARGET_DIMMAPPER_L')
CREATE TABLE T_EB_TARGET_DIMMAPPER_L
(
    FID       BIGINT       NOT NULL DEFAULT 0,
    FPKID     NVARCHAR(36) NOT NULL DEFAULT ' ',
    FLOCALEID NVARCHAR(10) NOT NULL DEFAULT ' ',
    FNAME     NVARCHAR(80) NOT NULL DEFAULT ' '
);
EXEC P_ALTERPK 'PK_T_EB_TARGET_DIMMAPPER_L', 'T_EB_TARGET_DIMMAPPER_L', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_TARGET_DIMMAPPER_L_NAME')
CREATE INDEX IDX_T_EB_TARGET_DIMMAPPER_L_NAME ON T_EB_TARGET_DIMMAPPER_L (FNAME);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_TARGET_MEMBERMAPPER')
CREATE TABLE T_EB_TARGET_MEMBERMAPPER
(
    FID             BIGINT       DEFAULT 0   NOT NULL,
    FENTRYID        BIGINT       DEFAULT 0   NOT NULL,
    FSEQ            INT          DEFAULT 0   NOT NULL,
    FSUBDIMENSION   NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FSCRMEMBER      NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FTARMEMBER      NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FSUBMEMBER      NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FSCRMEMBERNAME  NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FTARMEMBERNAME  NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FSUBMEMBERNAME  NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FSUBDIMENSIONID BIGINT
);
EXEC P_ALTERPK 'PK_T_EB_TARGET_MEMBERMAPPER', 'T_EB_TARGET_MEMBERMAPPER', 'FENTRYID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_TARGET_MEMBERMAPPER_FID')
CREATE INDEX IDX_T_EB_TARGET_MEMBERMAPPER_FID ON T_EB_TARGET_MEMBERMAPPER (FID);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_REPORT_SCHEME')
CREATE TABLE T_EB_REPORT_SCHEME
(
    FID         BIGINT       DEFAULT 0   NOT NULL,
    FNUMBER     NVARCHAR(30) DEFAULT ' ' NOT NULL,
    FSTATUS     NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FCREATORID  BIGINT,
    FMODIFIERID BIGINT,
    FENABLE     NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FCREATETIME DATETIME,
    FMODIFYTIME DATETIME,
    FMASTERID   BIGINT,
    FDATASETID  BIGINT,
    FMODEL      BIGINT,
    FTARGETID   BIGINT,
    FDATA       NCLOB
);
EXEC P_ALTERPK 'PK_T_EB_REPORT_SCHEME', 'T_EB_REPORT_SCHEME', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_REPORT_SCHEME')
CREATE INDEX IDX_T_EB_REPORT_SCHEME ON T_EB_REPORT_SCHEME (FNUMBER, FMODEL, FDATASETID, FTARGETID);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_REPORT_SCHEME_L')
CREATE TABLE T_EB_REPORT_SCHEME_L
(
    FID       BIGINT        NOT NULL DEFAULT 0,
    FPKID     NVARCHAR(36)  NOT NULL DEFAULT ' ',
    FLOCALEID NVARCHAR(10)  NOT NULL DEFAULT ' ',
    FNAME     NVARCHAR(100) NOT NULL DEFAULT ' '
);
EXEC P_ALTERPK 'PK_T_EB_REPORT_SCHEME_L', 'T_EB_REPORT_SCHEME_L', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_REPORT_SCHEME_L_NAME')
CREATE INDEX IDX_T_EB_REPORT_SCHEME_L_NAME ON T_EB_REPORT_SCHEME_L (FNAME);


/**End **/