/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDL_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_META_FEATURESBLACKLIST') 
 CREATE TABLE T_META_FEATURESBLACKLIST (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZAPP VARCHAR(36) DEFAULT ' ' NOT NULL,
FBIZCLOUD VARCHAR(36) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE() NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_ELEMENTCATEGORY') 
 CREATE TABLE T_DM_ELEMENTCATEGORY (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FXML VARCHAR(255) DEFAULT ' ' NOT NULL,
FXML_TAG NCLOB,
FISSYS CHAR(1) DEFAULT '0' NOT NULL,
FISV VARCHAR(50)
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DOMAINTYPE') 
 CREATE TABLE T_DM_DOMAINTYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FXML VARCHAR(255) DEFAULT ' ' NOT NULL,
FXML_TAG NCLOB,
FPARENT VARCHAR(50) DEFAULT ' ' NOT NULL,
FEXTEND CHAR(1) DEFAULT '0' NOT NULL,
FISSYS CHAR(1) DEFAULT '0' NOT NULL,
FPARENTNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_ELEMENTTYPEENTRY_L') 
 CREATE TABLE T_DM_ELEMENTTYPEENTRY_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FPROPERTYNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_ELEMENTTYPEENTRY') 
 CREATE TABLE T_DM_ELEMENTTYPEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FEXPAND CHAR(1) DEFAULT '0' NOT NULL,
FPROPERTYNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FTYPE VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_ELEMENTTYPE') 
 CREATE TABLE T_DM_ELEMENTTYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FISSYS CHAR(1) DEFAULT '0' NOT NULL,
FAPPLYNUMBER VARCHAR(500) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FISV VARCHAR(50) DEFAULT ' ' NOT NULL,
FCATEGORY VARCHAR(50) DEFAULT ' ' NOT NULL,
FCATEGORYXML VARCHAR(255) DEFAULT ' ' NOT NULL,
FCATEGORYXML_TAG NCLOB,
FMODELTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FPACKAGENAME VARCHAR(400) DEFAULT ' ' NOT NULL,
FXML VARCHAR(255) DEFAULT ' ' NOT NULL,
FXML_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_PROPERTY') 
 CREATE TABLE T_DM_PROPERTY (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FTYPE VARCHAR(50),
FXML VARCHAR(255) DEFAULT ' ' NOT NULL,
FXML_TAG NCLOB,
FISV VARCHAR(50),
FGROUPID VARCHAR(50)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_ELEMENTTYPE_L') 
 CREATE TABLE T_DM_ELEMENTTYPE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODELTYPENAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCATEGORYNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPPLYNUMBERNAME NVARCHAR(500)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_OPERATION') 
 CREATE TABLE T_DM_OPERATION (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FAPPLICATIONRANGE CHAR(1) DEFAULT '0' NOT NULL,
FFORMID VARCHAR(36),
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FMODELNUMBER VARCHAR(500) DEFAULT ' ' NOT NULL,
FISV VARCHAR(10) DEFAULT ' ' NOT NULL,
FFORMSERVICECLASS VARCHAR(500) DEFAULT ' ' NOT NULL,
FOPSERVICECLASS VARCHAR(500),
FWEBAPICLASS VARCHAR(500)
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_OPSERVICE') 
 CREATE TABLE T_DM_OPSERVICE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FFORMID VARCHAR(36),
FAPPLICATIONRANGE CHAR(1) DEFAULT '0' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FCLASS VARCHAR(500),
FISV VARCHAR(10) DEFAULT ' ' NOT NULL,
FOPWHITELIST VARCHAR(1000),
FOPBLACKLIST VARCHAR(1000)
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_RULE') 
 CREATE TABLE T_DM_RULE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FLOAD CHAR(1) DEFAULT '0' NOT NULL,
FFIELDCHANGED CHAR(1) DEFAULT '0' NOT NULL,
FCLASS VARCHAR(500),
FTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FFORMID VARCHAR(36) DEFAULT ' ' NOT NULL,
FADD CHAR(1) DEFAULT '0' NOT NULL,
FFORMRULE CHAR(1) DEFAULT '0' NOT NULL,
FLIST CHAR(1) DEFAULT '0' NOT NULL,
FREPORT CHAR(1) DEFAULT '0' NOT NULL,
FISV VARCHAR(10) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_VALIDATOR') 
 CREATE TABLE T_DM_VALIDATOR (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FERRORLEVEL VARCHAR(50),
FRUNCLASS VARCHAR(500),
FFORMID VARCHAR(36) DEFAULT ' ' NOT NULL,
FRANGE VARCHAR(10) DEFAULT ' ' NOT NULL,
FOPBLACKLIST VARCHAR(1000),
FOPWHITELIST VARCHAR(1000),
FISV VARCHAR(10) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_META_OBJECTTYPEREF' AND KSQL_COL_NAME ='FFIELDKEY') 
 ALTER TABLE T_META_OBJECTTYPEREF ADD (FFIELDKEY VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_META_BIZEXTCASE_L') 
 CREATE TABLE T_META_BIZEXTCASE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DMIMPORT') 
 CREATE TABLE T_DM_DMIMPORT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FDESC VARCHAR(250) DEFAULT ' ' NOT NULL,
FFILENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DMIMPORTENTRY') 
 CREATE TABLE T_DM_DMIMPORTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FFILENAME VARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_META_BIZEXTCASE') 
 CREATE TABLE T_META_BIZEXTCASE (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(200) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FINTERFACE VARCHAR(200) DEFAULT ' ' NOT NULL,
FSAMPLE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSAMPLE_TAG NCLOB,
FISV VARCHAR(200) DEFAULT ' ' NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FOBJECTTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FVERSION BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DMEXPORT') 
 CREATE TABLE T_DM_DMEXPORT (
FID BIGINT DEFAULT 0 NOT NULL,
FFILENAME VARCHAR(80) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FJARCOMBO VARCHAR(500) DEFAULT ' ' NOT NULL,
FCREATEDATE DATETIME,
FDESC VARCHAR(255) DEFAULT ' ' NOT NULL,
FJARNAME VARCHAR(500) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DMEXPORTENTRY') 
 CREATE TABLE T_DM_DMEXPORTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_META_BIZEXTPLUGIN_S') 
 CREATE TABLE T_META_BIZEXTPLUGIN_S (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_META_BIZEXTPLUGIN') 
 CREATE TABLE T_META_BIZEXTPLUGIN (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPLUGINCLASS VARCHAR(200) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(500) DEFAULT ' ' NOT NULL,
FISV VARCHAR(200) DEFAULT ' ' NOT NULL,
FISSYSDISABLE CHAR(1) DEFAULT '0' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FVERSION BIGINT DEFAULT 0 NOT NULL
);



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDL_table.sql **/
