/**Begin D:\k3Cloud\PDM_UPGRADE\PDM1\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROBABILITYCALDEF') 
 CREATE TABLE T_MDS_PROBABILITYCALDEF (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCTRLSTRATEGY VARCHAR(50) DEFAULT ' ' NOT NULL,
FISPRESET CHAR(1) DEFAULT '0' NOT NULL,
FSAMPLEDATA BIGINT DEFAULT 0 NOT NULL,
FHISTORYDATA BIGINT DEFAULT 0 NOT NULL,
FSAMPLEHISTORYFILTER NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FSAMPLEHISTORYFILTERVAL NCLOB,
FALGORITHMDEF BIGINT DEFAULT 0 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,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX BIGINT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROBABILITYCALDEF_L') 
 CREATE TABLE T_MDS_PROBABILITYCALDEF_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_PROBABILITYHP') 
 CREATE TABLE T_MDS_PROBABILITYHP (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FHPSELECTFILTER NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FHPSELECTFILTERVAL NCLOB,
FHPSELECTALL CHAR(1) DEFAULT '0' NOT NULL,
FHPDATASELECTNUM BIGINT DEFAULT 0 NOT NULL,
FHPSELECTDIMENSION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FHPSELECTDIMENSIONVAL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FHPSORT NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FHPSORTVAL NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROBABILITYRESULT') 
 CREATE TABLE T_MDS_PROBABILITYRESULT (
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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FACTYPE BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVGQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMAXQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMINQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEMONTHCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEACCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLEVEL VARCHAR(50) DEFAULT ' ' NOT NULL,
FUSEPROBABILITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUGGESTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVGDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLASTDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUGGESTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRENCY BIGINT DEFAULT 0 NOT NULL,
FLASTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FATANUMBER VARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPPLIER BIGINT DEFAULT 0 NOT NULL,
FSUPPLYTYPE VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROBABILITYRP') 
 CREATE TABLE T_MDS_PROBABILITYRP (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FRPSELECTFILTER NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FRPSELECTFILTERVAL NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROBABILITYSP') 
 CREATE TABLE T_MDS_PROBABILITYSP (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSPSELECTFILTER NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FSPSELECTFILTERVAL NCLOB,
FSPSELECTALL CHAR(1) DEFAULT '0' NOT NULL,
FSPDATASELECTNUM BIGINT DEFAULT 0 NOT NULL,
FSPSELECTDIMENSION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSPSELECTDIMENSIONVAL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSPSORT NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FSPSORTVAL NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SAMPLE') 
 CREATE TABLE T_MDS_SAMPLE (
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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL,
FACTYPE BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPE BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPEDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FACREGTEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPROJECT BIGINT DEFAULT 0 NOT NULL,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FUSE CHAR(1) DEFAULT '0' NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FSYSUSE CHAR(1) DEFAULT '0' NOT NULL,
FPROJECTCREATETIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SAMPLEHISRECORD') 
 CREATE TABLE T_MDS_SAMPLEHISRECORD (
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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSE CHAR(1) DEFAULT '0' NOT NULL,
FLOGID 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(255) DEFAULT ' ' NOT NULL,
FACREGTEXT NVARCHAR(255) DEFAULT ' ' 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,
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,
FSYSUSE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_STOCKUPSCHEME') 
 CREATE TABLE T_MDS_STOCKUPSCHEME (
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,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSEORG BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX BIGINT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX BIGINT DEFAULT 0 NOT NULL,
FPLANTYPE VARCHAR(5) DEFAULT ' ' NOT NULL,
FDATAFETCHSET BIGINT DEFAULT 0 NOT NULL,
FPROBABILITYCALDEF BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_STOCKUPSCHEME_L') 
 CREATE TABLE T_MDS_STOCKUPSCHEME_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_STOCKUPSTATUS') 
 CREATE TABLE T_MDS_STOCKUPSTATUS (
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,
FSTOCKUPSCHEME BIGINT DEFAULT 0 NOT NULL,
FBILLTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FPROJECTSTATUS BIGINT DEFAULT 0 NOT NULL,
FFORECASTVERSION NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSTOCKUPMODE VARCHAR(5) DEFAULT ' ' NOT NULL,
FSAMPLEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCHEDULEINTIME DATETIME,
FSCHEDULESTARTTIME DATETIME,
FSCHEDULEFINISHTIME DATETIME,
FSCHEDULELEAVETIME DATETIME,
FREPAIRCYCLE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTUALINTIME DATETIME,
FACTUALLEAVETIME DATETIME,
FPLANCREATOR BIGINT DEFAULT 0 NOT NULL,
FPLANCREATETIME DATETIME,
FPLANMODIFIER BIGINT DEFAULT 0 NOT NULL,
FPLANMODIFYTIME DATETIME,
FLISTCREATOR BIGINT DEFAULT 0 NOT NULL,
FLISTCREATETIME DATETIME,
FLISTMODIFIER BIGINT DEFAULT 0 NOT NULL,
FLISTMODIFYTIME DATETIME,
FWORKSCOPEID BIGINT DEFAULT 0 NOT NULL,
FAIRCRAFTPLAYID BIGINT DEFAULT 0 NOT NULL
);



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