/**Begin D:\k3Cloud\PDM_UPGRADE\PDM1\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_MATERIALBACKUP_L') 
 CREATE TABLE T_MDS_MATERIALBACKUP_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERAL') 
 CREATE TABLE T_MDS_GENERAL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERAL_L') 
 CREATE TABLE T_MDS_GENERAL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERALENTITY') 
 CREATE TABLE T_MDS_GENERALENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FREASONDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISLONGCYCLEMATER CHAR(1) DEFAULT '0' NOT NULL,
FENTRYCREATOR BIGINT DEFAULT 0 NOT NULL,
FENTRYCREATETIME DATETIME,
FENTRYMODIFIER BIGINT DEFAULT 0 NOT NULL,
FENTRYMODIFYTIME DATETIME,
FAPPLICANT BIGINT DEFAULT 0 NOT NULL,
FLOSEDATE DATETIME,
FEFFECTDATE DATETIME,
FACTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE BIGINT DEFAULT 0 NOT NULL,
FAVGDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLONGCYCLE DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_HISUSECALCLOG') 
 CREATE TABLE T_MDS_HISUSECALCLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FHISUSESET BIGINT DEFAULT 0 NOT NULL,
FLATEST CHAR(1) DEFAULT '0' NOT NULL,
FDATAFETCHSET BIGINT DEFAULT 0 NOT NULL,
FISTRANSFORM CHAR(1) DEFAULT '0' NOT NULL,
FCALSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCOUNT BIGINT DEFAULT 0 NOT NULL,
FSTARTTIME DATETIME,
FENDTIME DATETIME,
FSUMTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FERRMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FERRMSG_TAG NCLOB,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_HISUSECALCLOG_L') 
 CREATE TABLE T_MDS_HISUSECALCLOG_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_HISUSEDETAIL') 
 CREATE TABLE T_MDS_HISUSEDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FHISUSESET BIGINT DEFAULT 0 NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FACTYPE BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPE BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPEDESC NVARCHAR(80) DEFAULT ' ' NOT NULL,
FACREG BIGINT DEFAULT 0 NOT NULL,
FPROJECT BIGINT DEFAULT 0 NOT NULL,
FCARDTYPE BIGINT DEFAULT 0 NOT NULL,
FCARD BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FBILLQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEDATE DATETIME,
FBEFOREMATERIAL BIGINT DEFAULT 0 NOT NULL,
FBEFOREUNIT BIGINT DEFAULT 0 NOT NULL,
FMATERIALCHANGE CHAR(1) DEFAULT '0' NOT NULL,
FUNITCHANGE CHAR(1) DEFAULT '0' NOT NULL,
FATANUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FATACHAPTERNO BIGINT DEFAULT 0 NOT NULL,
FBIZTYPE BIGINT DEFAULT 0 NOT NULL,
FSUPPLYRESP VARCHAR(5) DEFAULT ' ' NOT NULL,
FORDERID BIGINT DEFAULT 0 NOT NULL,
FCONMTYPENAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPENUMBER VARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPEID VARCHAR(2000) DEFAULT ' ' NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_HISUSERESULT') 
 CREATE TABLE T_MDS_HISUSERESULT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY12M DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINSUPPLYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCUSTOSUPPLYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVERAGEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVERAGEQTY12M DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVERAGEDAYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVERAGEYEARQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQCODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISGENERAL CHAR(1) DEFAULT '0' NOT NULL,
FAVGDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLONGCYCLE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISLONGCYCLEMATER CHAR(1) DEFAULT '0' NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FACTYPE BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIALCHANGE CHAR(1) DEFAULT '0' NOT NULL,
FCONMTYPENAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPENUMBER VARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPEID VARCHAR(2000) DEFAULT ' ' NOT NULL,
FSUPPLYRESP VARCHAR(5) DEFAULT ' ' NOT NULL,
FQUARTER1 CHAR(1) DEFAULT '0' NOT NULL,
FQUARTER2 CHAR(1) DEFAULT '0' NOT NULL,
FQUARTER3 CHAR(1) DEFAULT '0' NOT NULL,
FQUARTER4 CHAR(1) DEFAULT '0' NOT NULL,
FMQTY1 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY2 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY3 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY4 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY5 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY6 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY7 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY8 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY9 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY10 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY11 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMQTY12 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERCOUNTALL BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT1 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT2 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT3 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT4 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT5 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT6 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT7 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT8 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT9 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT10 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT11 BIGINT DEFAULT 0 NOT NULL,
FORDERCOUNT12 BIGINT DEFAULT 0 NOT NULL,
FUSEMONTHCOUNT BIGINT DEFAULT 0 NOT NULL,
FDAYSTANDADEV12M DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMONTHSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDADEV12M DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDAYSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL,
FBEFOREMATERIAL BIGINT DEFAULT 0 NOT NULL,
FBEFOREUNIT BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_HISUSESET') 
 CREATE TABLE T_MDS_HISUSESET (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX BIGINT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX BIGINT DEFAULT 0 NOT NULL,
FDATAFETCHSET BIGINT DEFAULT 0 NOT NULL,
FISTRANSFORM CHAR(1) DEFAULT '0' NOT NULL,
FISSYS CHAR(1) DEFAULT '0' NOT NULL,
FSETVAL NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FPLANID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FJOBID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_HISUSESET_L') 
 CREATE TABLE T_MDS_HISUSESET_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_MATERIALBACKUP') 
 CREATE TABLE T_MDS_MATERIALBACKUP (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FNEWVERSION CHAR(1) DEFAULT '0' NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FAVGDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLASTDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNEWESTPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVERAGETIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVGPLANDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVGACTDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMINSTANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYRESP VARCHAR(5) DEFAULT ' ' NOT NULL,
FCONMTYPENAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPEID VARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPENUMBER VARCHAR(2000) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);



/**End D:\k3Cloud\PDM_UPGRADE\PDM1\MDS_table.sql **/
