/**Begin D:\k3Cloud\PDM_UPGRADE\PDM1\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FORECASTBYEQ') 
 CREATE TABLE T_MDS_FORECASTBYEQ (
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,
FORGID BIGINT 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,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEACCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEQCOUNTM1 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEQCOUNTM2 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEQCOUNTM3 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVERAGEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEPROBABILITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSHELFLIFE CHAR(1) DEFAULT '0' NOT NULL,
FISGENERAL CHAR(1) DEFAULT '0' NOT NULL,
FISLONGCYCLEMATER CHAR(1) DEFAULT '0' NOT NULL,
FMATERIALCHANGE CHAR(1) DEFAULT '0' NOT NULL,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FREQTIME DATETIME,
FEQCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL,
FSTOCKFACTOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFORECASTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FORECASTBYEQ_ATA') 
 CREATE TABLE T_MDS_FORECASTBYEQ_ATA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FORECASTBYTIME') 
 CREATE TABLE T_MDS_FORECASTBYTIME (
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,
FLOGID BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FSAFESTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FROP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FROQ DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTARGETSTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERCOUNTALL BIGINT DEFAULT 0 NOT NULL,
FUSEMONTHCOUNT BIGINT DEFAULT 0 NOT NULL,
FAVERAGEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVERAGEDAYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVGDELIVERY 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,
FDAYSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSHELFLIFE CHAR(1) DEFAULT '0' NOT NULL,
FQCODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FQUARTERFACTOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTOCKFACTOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSERVICEFACTOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELIVERYFACTOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISGENERAL CHAR(1) DEFAULT '0' NOT NULL,
FISLONGCYCLEMATER CHAR(1) DEFAULT '0' NOT NULL,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FREQTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FORECASTBYTIME_ATA') 
 CREATE TABLE T_MDS_FORECASTBYTIME_ATA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERALLOG') 
 CREATE TABLE T_MDS_GENERALLOG (
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,
FGENERALSET BIGINT DEFAULT 0 NOT NULL,
FSPECIALCOND CHAR(1) DEFAULT '0' NOT NULL,
FLATEST CHAR(1) DEFAULT '0' NOT NULL,
FGENERALPLAN BIGINT DEFAULT 0 NOT NULL,
FREPEATCAL CHAR(1) DEFAULT '0' NOT NULL,
FHISUSESET BIGINT DEFAULT 0 NOT NULL,
FUSECOUNTMIN BIGINT DEFAULT 0 NOT NULL,
FUSECOUNTMAX BIGINT DEFAULT 0 NOT NULL,
FSPECIALREQ CHAR(1) DEFAULT '0' NOT NULL,
FCALSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FSTARTTIME DATETIME,
FENDTIME DATETIME,
FSUMTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FERRMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FERRMSG_TAG NCLOB,
FPLANCOUNT BIGINT DEFAULT 0 NOT NULL,
FACTYPECOUNT BIGINT DEFAULT 0 NOT NULL,
FCUSTOMERCOUNT BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPECOUNT BIGINT DEFAULT 0 NOT NULL,
FPLANSTARTTIME DATETIME,
FPLANENDTIME DATETIME,
FPLANSUMTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FHISUSECALCLOG BIGINT DEFAULT 0 NOT NULL,
FTARGETSTARTTIME DATETIME,
FTARGETENDTIME DATETIME,
FTARGETSUMTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPECIALNOCOUNT BIGINT DEFAULT 0 NOT NULL,
FSPECIALSTARTTIME DATETIME,
FSPECIALENDTIME DATETIME,
FSPECIALSUMTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTOCKNOCOUNT BIGINT DEFAULT 0 NOT NULL,
FSUGSTARTTIME DATETIME,
FSUGENDTIME DATETIME,
FSUGSUMTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERALLOG_L') 
 CREATE TABLE T_MDS_GENERALLOG_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_GENERALPLAN') 
 CREATE TABLE T_MDS_GENERALPLAN (
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,
FORGID 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(50) DEFAULT ' ' NOT NULL,
FACREG BIGINT DEFAULT 0 NOT NULL,
FPROJECT BIGINT DEFAULT 0 NOT NULL,
FPROJECTCREATETIME DATETIME,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FREPAIRCYCLE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERALSET') 
 CREATE TABLE T_MDS_GENERALSET (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSPECIALCOND CHAR(1) DEFAULT '0' NOT NULL,
FGENERALPLAN BIGINT DEFAULT 0 NOT NULL,
FISSYS CHAR(1) DEFAULT '0' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FREPEATCAL CHAR(1) DEFAULT '0' NOT NULL,
FHISUSESET BIGINT DEFAULT 0 NOT NULL,
FUSECOUNTMIN BIGINT DEFAULT 0 NOT NULL,
FUSECOUNTMAX BIGINT DEFAULT 0 NOT NULL,
FSPECIALREQ CHAR(1) 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,
FCUSANDACTYPE CHAR(1) DEFAULT '0' NOT NULL,
FCHECKTYPECOUNT BIGINT DEFAULT 0 NOT NULL,
FACTYPE CHAR(1) DEFAULT '0' NOT NULL,
FCUSTOMERCOUNT BIGINT DEFAULT 0 NOT NULL,
FCUSTOMER CHAR(1) DEFAULT '0' NOT NULL,
FACTYPECOUNT BIGINT DEFAULT 0 NOT NULL,
FISALL 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_GENERALSET_GROUP') 
 CREATE TABLE T_MDS_GENERALSET_GROUP (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERALSET_L') 
 CREATE TABLE T_MDS_GENERALSET_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_GENERALSUG_ENTRY') 
 CREATE TABLE T_MDS_GENERALSUG_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE BIGINT DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FTARGETSTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFORECASTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCALSTOCKLEVEL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSPECIALREQ DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCALMETHOD VARCHAR(5) DEFAULT ' ' NOT NULL,
FSUGGESTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLASTADJREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FADJREASONFLAG CHAR(1) DEFAULT '0' NOT NULL,
FISLONGCYCLEMATER CHAR(1) DEFAULT '0' NOT NULL,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FREQTIME DATETIME,
FSTOCKUPMODE VARCHAR(5) DEFAULT ' ' NOT NULL,
FENTRYMODIFIER BIGINT DEFAULT 0 NOT NULL,
FENTRYMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERALSUGGEST') 
 CREATE TABLE T_MDS_GENERALSUGGEST (
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,
FLOGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_GENERALSUGGEST_ATA') 
 CREATE TABLE T_MDS_GENERALSUGGEST_ATA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_MATERIALPARAM') 
 CREATE TABLE T_MDS_MATERIALPARAM (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FISSYS CHAR(1) DEFAULT '0' NOT NULL,
FMATERIALGROUP BIGINT DEFAULT 0 NOT NULL,
FAVGQTY VARCHAR(5) DEFAULT ' ' NOT NULL,
FDELIVERYDATE VARCHAR(5) DEFAULT ' ' NOT NULL,
FQUARTERFACTOR NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FSTOCKFACTOR NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FSERVICEFACTOR NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FACSTOCKFACTOR NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FLONGCYCLE BIGINT DEFAULT 0 NOT NULL,
FAVGDELIVERY BIGINT DEFAULT 0 NOT NULL,
FDELSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELIVERYFACTOR BIGINT DEFAULT 0 NOT NULL,
FDELIVERYFACTORNO BIGINT DEFAULT 0 NOT NULL,
FINVENTORYLEVELLOW VARCHAR(5) DEFAULT ' ' NOT NULL,
FINVENTORYLEVELHIGH VARCHAR(5) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_MATERIALPARAM_L') 
 CREATE TABLE T_MDS_MATERIALPARAM_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_PROBALOG_BIZTYPE') 
 CREATE TABLE T_MDS_PROBALOG_BIZTYPE (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROBALOG_CABIN') 
 CREATE TABLE T_MDS_PROBALOG_CABIN (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROBALOG_POLARIS') 
 CREATE TABLE T_MDS_PROBALOG_POLARIS (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_TARGETM_TIME_ATA') 
 CREATE TABLE T_MDS_TARGETM_TIME_ATA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_TARGETMATERI_EQ_ATA') 
 CREATE TABLE T_MDS_TARGETMATERI_EQ_ATA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_TARGETMATERIAL_ATA') 
 CREATE TABLE T_MDS_TARGETMATERIAL_ATA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_TARGETMATERIAL_EQ') 
 CREATE TABLE T_MDS_TARGETMATERIAL_EQ (
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,
FORGID BIGINT 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,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEACCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEQCOUNTM1 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEQCOUNTM2 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEQCOUNTM3 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVERAGEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEPROBABILITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSHELFLIFE CHAR(1) DEFAULT '0' NOT NULL,
FISGENERAL CHAR(1) DEFAULT '0' NOT NULL,
FISLONGCYCLEMATER CHAR(1) DEFAULT '0' NOT NULL,
FMATERIALCHANGE CHAR(1) DEFAULT '0' NOT NULL,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FREQTIME DATETIME,
FEQCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_TARGETMATERIAL_TIME') 
 CREATE TABLE T_MDS_TARGETMATERIAL_TIME (
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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE BIGINT DEFAULT 0 NOT NULL,
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,
FUSEMONTHCOUNT BIGINT 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,
FMONTHSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDADEV12M DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDAYSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDAYSTANDADEV12M 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,
FQCODE NVARCHAR(50) 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,
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,
FMATERIALCHANGE CHAR(1) DEFAULT '0' NOT NULL,
FCONMTYPENAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPENUMBER NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPEID NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FBEFOREMATERIAL BIGINT DEFAULT 0 NOT NULL,
FBEFOREMATERIALNUMBER NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FBEFOREMATERIALNAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FBEFOREUNIT BIGINT DEFAULT 0 NOT NULL,
FBEFOREUNITNAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FSUPPLYRESP VARCHAR(5) DEFAULT ' ' NOT NULL,
FSHELFLIFE CHAR(1) DEFAULT '0' NOT NULL,
FTARGETFLAG CHAR(1) DEFAULT '0' NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FREQTIME DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_TARGETMATERIAL') 
 CREATE TABLE T_MDS_TARGETMATERIAL (
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,
FORGID BIGINT 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,
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,
FUSEMONTHCOUNT BIGINT 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,
FMONTHSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDADEV12M DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDAYSTANDADEV DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDAYSTANDADEV12M 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,
FQCODE NVARCHAR(50) 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,
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,
FMATERIALCHANGE CHAR(1) DEFAULT '0' NOT NULL,
FCONMTYPENAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPENUMBER NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCONMTYPEID NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FBEFOREMATERIAL BIGINT DEFAULT 0 NOT NULL,
FBEFOREMATERIALNUMBER NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FBEFOREMATERIALNAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FBEFOREUNIT BIGINT DEFAULT 0 NOT NULL,
FBEFOREUNITNAME NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FSUPPLYRESP VARCHAR(5) DEFAULT ' ' NOT NULL,
FSHELFLIFE CHAR(1) DEFAULT '0' NOT NULL,
FTARGETFLAG CHAR(1) DEFAULT '0' NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FREQTIME DATETIME
);

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