/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CENTRALIZED_ENTITY' AND KSQL_COL_NAME ='FDIMENSION') 
 ALTER TABLE T_EB_CENTRALIZED_ENTITY ADD (FDIMENSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CENTRALIZED_ENTITY' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_EB_CENTRALIZED_ENTITY ADD (FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CENTRALIZED_RANGE' AND KSQL_COL_NAME ='FDIMENSIONRANGE') 
 ALTER TABLE T_EB_CENTRALIZED_RANGE ADD (FDIMENSIONRANGE NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_STRUCTOFENT' AND KSQL_COL_NAME ='FOFFSETSOURCE') 
 ALTER TABLE T_EB_STRUCTOFENT ADD (FOFFSETSOURCE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXAMINE_DIMSET') 
 CREATE TABLE T_EB_EXAMINE_DIMSET (
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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_EXAMINECATEGORY' AND KSQL_COL_NAME ='FBUSINESSMODEL') 
 ALTER TABLE T_EB_EXAMINECATEGORY ADD (FBUSINESSMODEL BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_EXAMINE' AND KSQL_COL_NAME ='FDIMSETINFO') 
 ALTER TABLE T_EB_EXAMINE ADD (FDIMSETINFO NVARCHAR(2000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CHANGETYPEFORMULA') 
 CREATE TABLE T_EB_CHANGETYPEFORMULA (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FFORMULVIEWID BIGINT DEFAULT 0 NOT NULL,
FFORMULA NCLOB,
FFORMULANAME NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MEMBERSAVESELECT') 
 CREATE TABLE T_EB_MEMBERSAVESELECT (
FID BIGINT DEFAULT 0 NOT NULL,
FMEMBERID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FRANGE CHAR(1) DEFAULT '0' NOT NULL,
FLEVELCOUNT CHAR(2) DEFAULT ' ' NOT NULL,
FCURLEVEL INT DEFAULT 0 NOT NULL,
FSOURCE CHAR(1) DEFAULT '0' NOT NULL,
FVIEWID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_BIZRULEOPTIMIZE') 
 CREATE TABLE T_EB_BIZRULEOPTIMIZE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FONEDIMTHRESHOLD INT DEFAULT 0 NOT NULL,
FALLDIMTHRESHOLD INT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_BIZRULESET' AND KSQL_COL_NAME ='FOPTIMIZE') 
 ALTER TABLE T_EB_BIZRULESET ADD (FOPTIMIZE CHAR(1) DEFAULT '0' NOT NULL );

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CENTRALIZED_ENTITY_L') 
 CREATE TABLE T_EB_CENTRALIZED_ENTITY_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);



 --- drop TABLE --------- 不允许删除表T_EB_EXAMINE_DIMGROP，请恢复pdm ------------------- 

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