/**Begin D:\PDM_UPGRADE\PDM1\EB_constraint.sql **/
-- T_EB_CONTROLRULEDEF_BAK，新增控制方式自定义维度成员表备份表，用于备份控制方式自定义维度成员表中分组控制方式的数据，原表T_EB_CONTROLRULEDEFINEDS_BACKUP在Oracle新建表表名过长先删再增新表
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CONTROLRULEDEFINEDS_BACKUP') 
DROP TABLE T_EB_CONTROLRULEDEFINEDS_BACKUP;

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CONTROLRULEDEF_BAK') 
CREATE TABLE T_EB_CONTROLRULEDEF_BAK (
   FENTRYID             BIGINT               NOT NULL DEFAULT 0,
   FID                  BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDID1      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDID2      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDID3      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDID4      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDID5      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDID6      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDID7      BIGINT               NOT NULL DEFAULT 0,
   FSEQ      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDDIMID1      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDDIMID2      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDDIMID3      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDDIMID4      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDDIMID5      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDDIMID6      BIGINT               NOT NULL DEFAULT 0,
   FUSERDEFINEDDIMID7      BIGINT               NOT NULL DEFAULT 0,
   FGROUPACCOUNT           BIGINT               NULL
);
EXEC P_ALTERPK 'PK_T_EB_CONTROLRULEDEF_BAK', 'T_EB_CONTROLRULEDEF_BAK', 'FENTRYID', '1';
 
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_CONTROLRULEDEF_BAK')
CREATE INDEX IDX_EB_CONTROLRULEDEF_BAK ON T_EB_CONTROLRULEDEF_BAK (
FID ASC
);

/**End D:\PDM_UPGRADE\PDM1\EB_constraint.sql **/