/* 删除原来的表 */
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG') 
DROP TABLE T_PERM_LOG;

IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_ARCHIVE') 
DROP TABLE T_PERM_LOG_ARCHIVE;

IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_USER') 
DROP TABLE T_PERM_LOG_USER;

IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_SETTING') 
DROP TABLE T_PERM_LOG_SETTING;

/* 重建使用的表 */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_USER') 
 CREATE TABLE T_PERM_LOG_USER (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FUSER_ID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSER_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(36) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK VARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG') 
 CREATE TABLE T_PERM_LOG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER BIGINT DEFAULT 0 NOT NULL,
FBUSI_FROM VARCHAR(100) DEFAULT ' ' NOT NULL,
FBUSI_TYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFORM_IDENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FFORM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOP NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOPBTN NVARCHAR(100) DEFAULT ' ' NOT NULL,
FINTERFACE_METHOD VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_ITEM_ID VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_ITEM_NUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_ITEM_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPRE_DATA NCLOB,
FAFTER_DATA NCLOB,
FDIFF_CONTENT NCLOB,
FOPER_ID BIGINT DEFAULT 0 NOT NULL,
FOPER_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPER_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FOPER_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPER_ORG_ID BIGINT DEFAULT 0 NOT NULL,
FOPER_ORG_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPER_TIME DATETIME,
FOP_DESC NCLOB,
FCLIENT_TYPE VARCHAR(300) DEFAULT ' ' NOT NULL,
FCLIENT_IP VARCHAR(300) DEFAULT ' ' NOT NULL,
FCLIENT_NAME VARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FMODIFY_TIME DATETIME,
FHAS_GENDIFF CHAR(1) DEFAULT '0' NOT NULL,
FFILING_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_FUNCPERM') 
 CREATE TABLE T_PERM_LOG_DIFF_FUNCPERM (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_FIELDPERM') 
 CREATE TABLE T_PERM_LOG_DIFF_FIELDPERM (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELD_NAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELD_COMMENT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTROL_MODE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FCONTROL_MODEDESC NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_NEWDR') 
 CREATE TABLE T_PERM_LOG_DIFF_NEWDR (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRE_DATA_RULEID BIGINT DEFAULT 0 NOT NULL,
FPRE_DATA_RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FAFTER_DATA_RULEID BIGINT DEFAULT 0 NOT NULL,
FAFTER_DATA_RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_NEWDRPROP') 
 CREATE TABLE T_PERM_LOG_DIFF_NEWDRPROP (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROP_KEY VARCHAR(60) DEFAULT ' ' NOT NULL,
FPROP_NAME NVARCHAR(60) DEFAULT ' ' NOT NULL,
FPROP_ENTNUM VARCHAR(60) DEFAULT ' ' NOT NULL,
FPROP_ENTNAME NVARCHAR(60) DEFAULT ' ' NOT NULL,
FPRE_DATA_RULEID BIGINT DEFAULT 0 NOT NULL,
FPRE_DATA_RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FAFTER_DATA_RULEID BIGINT DEFAULT 0 NOT NULL,
FAFTER_DATA_RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DIMUSER') 
 CREATE TABLE T_PERM_LOG_DIFF_DIMUSER (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FUSER_ID BIGINT DEFAULT 0 NOT NULL,
FUSER_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUSER_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSER_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(36) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_COMMROLE') 
 CREATE TABLE T_PERM_LOG_DIFF_COMMROLE (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FROLE_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FROLE_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FOP_ENABLE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_BCPERM') 
 CREATE TABLE T_PERM_LOG_DIFF_BCPERM (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DISPERM') 
 CREATE TABLE T_PERM_LOG_DIFF_DISPERM (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DIMRANGE') 
 CREATE TABLE T_PERM_LOG_DIFF_DIMRANGE (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_USER') 
 CREATE TABLE T_PERM_LOG_DIFF_USER (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FUSER_ID BIGINT DEFAULT 0 NOT NULL,
FUSER_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUSER_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSER_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(36) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DIMFUNC') 
 CREATE TABLE T_PERM_LOG_DIFF_DIMFUNC (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DIMFIELD') 
 CREATE TABLE T_PERM_LOG_DIFF_DIMFIELD (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELD_NAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELD_COMMENT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTROL_MODE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FCONTROL_MODEDESC NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DIMNEWDR') 
 CREATE TABLE T_PERM_LOG_DIFF_DIMNEWDR (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FPRE_DATA_RULEID BIGINT DEFAULT 0 NOT NULL,
FPRE_DATA_RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FAFTER_DATA_RULEID BIGINT DEFAULT 0 NOT NULL,
FAFTER_DATA_RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DIMNEWDRP') 
 CREATE TABLE T_PERM_LOG_DIFF_DIMNEWDRP (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROP_KEY VARCHAR(60) DEFAULT ' ' NOT NULL,
FPROP_NAME NVARCHAR(60) DEFAULT ' ' NOT NULL,
FPROP_ENTNUM VARCHAR(60) DEFAULT ' ' NOT NULL,
FPROP_ENTNAME NVARCHAR(60) DEFAULT ' ' NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FPRE_DATA_RULEID BIGINT DEFAULT 0 NOT NULL,
FPRE_DATA_RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FAFTER_DATA_RULEID BIGINT DEFAULT 0 NOT NULL,
FAFTER_DATA_RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DIMDIS') 
 CREATE TABLE T_PERM_LOG_DIFF_DIMDIS (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DIMROLE') 
 CREATE TABLE T_PERM_LOG_DIFF_DIMROLE (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FROLE_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FROLE_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_BUSIROLE') 
 CREATE TABLE T_PERM_LOG_DIFF_BUSIROLE (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FROLE_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FROLE_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_COPYTARUSER') 
 CREATE TABLE T_PERM_LOG_COPYTARUSER (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FUSER_ID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSER_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_BUSIUNIT') 
 CREATE TABLE T_PERM_LOG_DIFF_BUSIUNIT (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FBUSIUNIT_ID BIGINT DEFAULT 0 NOT NULL,
FBUSIUNIT_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FBUSIUNIT_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_ADMORG') 
 CREATE TABLE T_PERM_LOG_DIFF_ADMORG (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FADMORG_ID BIGINT DEFAULT 0 NOT NULL,
FADMORG_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FADMORG_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_APP') 
 CREATE TABLE T_PERM_LOG_DIFF_APP (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_ADMORGUSR') 
 CREATE TABLE T_PERM_LOG_DIFF_ADMORGUSR (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FUSER_ID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSER_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(36) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_OPRINFO') 
 CREATE TABLE T_PERM_LOG_DIFF_OPRINFO (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPERATION NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOPERATION_KEY VARCHAR(30) DEFAULT ' ' NOT NULL,
FOPERATION_TYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FISPUBLIC CHAR(1) DEFAULT '0' NOT NULL,
FISPRESET CHAR(1) DEFAULT '0' NOT NULL,
FRULE NCLOB,
FOPERATIONRULE_OBJID VARCHAR(18) DEFAULT ' ' NOT NULL,
FOBJENABLED CHAR(1) DEFAULT '0' NOT NULL,
FNAME_AFTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPERATION_AFTER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOPERATION_KEY_AFTER VARCHAR(30) DEFAULT ' ' NOT NULL,
FOPERATION_TYPE_AFTER VARCHAR(30) DEFAULT ' ' NOT NULL,
FISPUBLIC_AFTER CHAR(1) DEFAULT '0' NOT NULL,
FISPRESET_AFTER CHAR(1) DEFAULT '0' NOT NULL,
FRULE_AFTER NCLOB,
FOPERATIONRULE_OBJID_AFTER VARCHAR(18) DEFAULT ' ' NOT NULL,
FOBJENABLED_AFTER CHAR(1) DEFAULT '0' NOT NULL,
FCREATE_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_OPRDIRECT') 
 CREATE TABLE T_PERM_LOG_DIFF_OPRDIRECT (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FDIRECTOR_ID BIGINT DEFAULT 0 NOT NULL,
FDIRECTOR_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIRECTOR_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FDIRECTOR_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(36) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FPOSITION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FORG_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_OPREXUSR') 
 CREATE TABLE T_PERM_LOG_DIFF_OPREXUSR (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FUSER_ID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSER_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(36) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FPOSITION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FORG_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_OPREXUSGR') 
 CREATE TABLE T_PERM_LOG_DIFF_OPREXUSGR (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FUSRGRP_ID BIGINT DEFAULT 0 NOT NULL,
FUSRGRP_NUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FUSRGRP_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FUSRGRP_DESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_OPREXROLE') 
 CREATE TABLE T_PERM_LOG_DIFF_OPREXROLE (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FROLE_ID VARCHAR(18) DEFAULT ' ' NOT NULL,
FROLE_NUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FROLE_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FROLE_REMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_FAILMSG') 
 CREATE TABLE T_PERM_LOG_DIFF_FAILMSG (
FID BIGINT DEFAULT 0 NOT NULL,
FMESSAGE NCLOB DEFAULT ' ',
FRETRYTIMES BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FNEXTRETRYTIME BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_DRINFO') 
 CREATE TABLE T_PERM_LOG_DIFF_DRINFO (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FENTITY_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDR_NUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDR_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRULE NCLOB,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FDR_NUMBER_AFTER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDR_NAME_AFTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRULE_AFTER NCLOB,
FENABLE_AFTER CHAR(1) DEFAULT '1' NOT NULL,
FCREATE_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_ARCHIVE') 
 CREATE TABLE T_PERM_LOG_ARCHIVE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER BIGINT DEFAULT 0 NOT NULL,
FBUSI_FROM VARCHAR(100) DEFAULT ' ' NOT NULL,
FBUSI_TYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FCLOUD_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCLOUD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAPP_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPP_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFORM_IDENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FFORM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPERM_ITEM_ID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERM_ITEM_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOP NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOPBTN NVARCHAR(100) DEFAULT ' ' NOT NULL,
FINTERFACE_METHOD VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_ITEM_ID VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_ITEM_NUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
FOP_ITEM_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPRE_DATA NCLOB,
FAFTER_DATA NCLOB,
FDIFF_CONTENT NCLOB,
FOPER_ID BIGINT DEFAULT 0 NOT NULL,
FOPER_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPER_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FOPER_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPER_ORG_ID BIGINT DEFAULT 0 NOT NULL,
FOPER_ORG_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPER_TIME DATETIME,
FOP_DESC NCLOB,
FCLIENT_TYPE VARCHAR(300) DEFAULT ' ' NOT NULL,
FCLIENT_IP VARCHAR(300) DEFAULT ' ' NOT NULL,
FCLIENT_NAME VARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FMODIFY_TIME DATETIME,
FHAS_GENDIFF CHAR(1) DEFAULT '0' NOT NULL,
FFILING_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BDLOG_SETTING') 
 CREATE TABLE T_BDLOG_SETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FLOG_TYPE VARCHAR(128) DEFAULT ' ' NOT NULL,
FENABLE_LOG CHAR(1) DEFAULT '0' NOT NULL,
FARCHIVEA_PERIOD INT DEFAULT 0 NOT NULL,
FAUTO_ARCHIVEA BIGINT DEFAULT 0 NOT NULL,
FARCHIVEA_RETAINDAYS INT DEFAULT 0 NOT NULL,
FARCHIVED_COUNT BIGINT DEFAULT 0 NOT NULL,
FAUTO_CLEARTIMES BIGINT DEFAULT 0 NOT NULL,
FCREATE_TIME DATETIME,
FMODIFY_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BDLOG_INDEX') 
 CREATE TABLE T_BDLOG_INDEX (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLOG_TYPE VARCHAR(128) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCAPACITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDOCS BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BDLOG_FAILMSG') 
 CREATE TABLE T_BDLOG_FAILMSG (
FID BIGINT DEFAULT 0 NOT NULL,
FMESSAGE NCLOB DEFAULT ' ',
FRETRYTIMES BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FNEXTRETRYTIME BIGINT DEFAULT 0 NOT NULL
);




