/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest(平台_业务)\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DIMMAPINGENTRY') 
 CREATE TABLE T_BCM_DIMMAPINGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSRCDIMID BIGINT DEFAULT 0 NOT NULL,
FTAGDIMID BIGINT DEFAULT 0 NOT NULL,
FDEFAULTITEMID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DIMMEMBERMAPPING') 
 CREATE TABLE T_BCM_DIMMEMBERMAPPING (
FID BIGINT DEFAULT 0 NOT NULL,
FSRCDIMID BIGINT DEFAULT 0 NOT NULL,
FTAGDIMID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INTEGRATESCHEME') 
 CREATE TABLE T_BCM_INTEGRATESCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCDATASYSID BIGINT DEFAULT 0 NOT NULL,
FTARGETDATASYSID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME,
FSCHEMECATALOGID BIGINT DEFAULT 0 NOT NULL,
FSCHEMESTATUS CHAR(1) DEFAULT '0' NOT NULL,
FCREATERID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INTEGRATESCHEME_L') 
 CREATE TABLE T_BCM_INTEGRATESCHEME_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_PERIODSRCDIM') 
 CREATE TABLE T_BCM_PERIODSRCDIM (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FENTITYNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSYSSOURCE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_PERIODSRCDIM_L') 
 CREATE TABLE T_BCM_PERIODSRCDIM_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SCHEMECATALOG') 
 CREATE TABLE T_BCM_SCHEMECATALOG (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FCREATEORID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FLEVEL BIGINT DEFAULT 0 NOT NULL,
FLONGNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISLEAF CHAR(1) DEFAULT '0' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SCHEMECATALOG_L') 
 CREATE TABLE T_BCM_SCHEMECATALOG_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FFULLNAME VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SCHEMEEASSIGN') 
 CREATE TABLE T_BCM_SCHEMEEASSIGN (
FID BIGINT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FENTITY BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FTEXTNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROPERTY BIGINT DEFAULT 0 NOT NULL,
FPROPERTYVALUE BIGINT DEFAULT 0 NOT NULL,
FRANGE NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SRCDIMBASEDATA') 
 CREATE TABLE T_BCM_SRCDIMBASEDATA (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FENTITYNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSYSSOURCE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SRCDIMBASEDATA_L') 
 CREATE TABLE T_BCM_SRCDIMBASEDATA_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_YEARSRCDIM') 
 CREATE TABLE T_BCM_YEARSRCDIM (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FENTITYNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSYSSOURCE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_YEARSRCDIM_L') 
 CREATE TABLE T_BCM_YEARSRCDIM_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DIMCOMBMAPPING') 
 CREATE TABLE T_BCM_DIMCOMBMAPPING (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DIMMEMBCOMBENTRY') 
 CREATE TABLE T_BCM_DIMMEMBCOMBENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRELATION CHAR(1) DEFAULT '0' NOT NULL,
FSRCDIM1 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM2 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM3 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM4 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM5 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM6 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM7 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM8 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM9 BIGINT DEFAULT 0 NOT NULL,
FSRCDIM10 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM1 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM2 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM3 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM4 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM5 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM6 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM7 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM8 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM9 BIGINT DEFAULT 0 NOT NULL,
FTAGDIM10 BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DIMMEMBENTRY') 
 CREATE TABLE T_BCM_DIMMEMBENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRELATION CHAR(1) DEFAULT '0' NOT NULL,
FTAGDIMMEMBNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FTAGDIMMEMB BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SRCDIMMEMBENTRY') 
 CREATE TABLE T_BCM_SRCDIMMEMBENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCDIMMEMBNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCDIMMEMBID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TEMPLATE' AND KSQL_COL_NAME IN ('FEXCELDATA')) 
 ALTER TABLE T_BCM_TEMPLATE ADD (FEXCELDATA BLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DIMMAPPING') 
 CREATE TABLE T_BCM_DIMMAPPING (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL
);



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest(平台_业务)\pdm\BCM_table.sql **/
