/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\kd_1.5.1_bcm_table_190723.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_METRICMEMBER') 
 CREATE TABLE T_BCM_METRICMEMBER (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_STRUCTOFMETRIC') 
 CREATE TABLE T_BCM_STRUCTOFMETRIC (
FID BIGINT DEFAULT 0 NOT NULL,
FLONGNUMBER NVARCHAR(200) DEFAULT ' ' NOT NULL,
FMEMBERID BIGINT DEFAULT 0 NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FISLEAF CHAR(1) DEFAULT ' ' NOT NULL,
FLEVEL INT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTORAGETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FAGGOPRT CHAR(1) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSHAREALL INT DEFAULT 0 NOT NULL,
FDPROPERTYID1 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID2 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID3 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID4 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID5 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID6 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID7 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID8 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID9 BIGINT DEFAULT 0 NOT NULL,
FDPROPERTYID10 BIGINT DEFAULT 0 NOT NULL,
FISSYSMEMBER INT DEFAULT 0 NOT NULL,
FCOPYFROM BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FREFERID BIGINT DEFAULT 0 NOT NULL,
FVERSIONTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDATATYPE NVARCHAR(30) DEFAULT ' ' NOT NULL
);


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


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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DATETYPEEDITCYCLE' AND KSQL_COL_NAME IN ('FINDEX')) 
 ALTER TABLE T_BCM_DATETYPEEDITCYCLE  ADD (FINDEX  INT  DEFAULT 0 NOT NULL );
 
 /**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\kd_1.5.1_bcm_table_190723.sql **/