
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LOG_APP_V2') 
 CREATE TABLE T_LOG_APP_V2 (
FID VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FBIZOBJID VARCHAR(36) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBIZAPPNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBIZOBJNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORGNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPTIME DATETIME,
FCLIENTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCLIENTIP VARCHAR(128) DEFAULT ' ' NOT NULL,
FARCHIVETIME DATETIME,
FOPNAMEE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPDESCRIPTIONE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCLIENTNAMEE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMODIFYBILLID VARCHAR(36) DEFAULT ' ' NOT NULL,
FMODIFYCONTENT NVARCHAR(510),
FMODIFYCONTENT_TAG NCLOB,
FMODIFYFIELDS VARCHAR(1020) DEFAULT ' ' NOT NULL,
FMODIFYBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LOG_APP_ARCHIVE_V2') 
 CREATE TABLE T_LOG_APP_ARCHIVE_V2 (
FID VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FBIZOBJID VARCHAR(36) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBIZAPPNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBIZOBJNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORGNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPTIME DATETIME,
FCLIENTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCLIENTIP VARCHAR(128) DEFAULT ' ' NOT NULL,
FARCHIVETIME DATETIME,
FOPNAMEE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPDESCRIPTIONE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCLIENTNAMEE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMODIFYBILLID VARCHAR(36) DEFAULT ' ' NOT NULL,
FMODIFYCONTENT NVARCHAR(510),
FMODIFYCONTENT_TAG NCLOB,
FMODIFYFIELDS VARCHAR(1020) DEFAULT ' ' NOT NULL,
FMODIFYBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LOG_APP_OTHER') 
 CREATE TABLE T_LOG_APP_OTHER (
FID VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FBIZOBJID VARCHAR(36) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBIZAPPNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBIZOBJNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORGNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPTIME DATETIME,
FCLIENTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCLIENTIP VARCHAR(128) DEFAULT ' ' NOT NULL,
FARCHIVETIME DATETIME,
FOPNAMEE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPDESCRIPTIONE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCLIENTNAMEE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMODIFYBILLID VARCHAR(36) DEFAULT ' ' NOT NULL,
FMODIFYCONTENT NVARCHAR(510),
FMODIFYCONTENT_TAG NCLOB,
FMODIFYFIELDS VARCHAR(1020) DEFAULT ' ' NOT NULL,
FMODIFYBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL
);


 EXEC P_ALTERPK 'PK_T_LOG_APP_V2', 'T_LOG_APP_V2', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOG_APPV2_OPTIMEAPPUSER') CREATE INDEX IDX_LOG_APPV2_OPTIMEAPPUSER ON T_LOG_APP_V2 ( FOPTIME ,FBIZAPPID ,FUSERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOG_APPV2_MODIFYBILLID') CREATE INDEX IDX_LOG_APPV2_MODIFYBILLID ON T_LOG_APP_V2 ( FMODIFYBILLID );


 EXEC P_ALTERPK 'PK_T_LOG_APP_ARCHIVE_V2', 'T_LOG_APP_ARCHIVE_V2', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGV2_ARCHIVE_OPUSER') CREATE INDEX IDX_LOGV2_ARCHIVE_OPUSER ON T_LOG_APP_ARCHIVE_V2 ( FOPTIME ,FBIZAPPID ,FUSERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGV2_ARCHIV_MODIFYBILLID') CREATE INDEX IDX_LOGV2_ARCHIV_MODIFYBILLID ON T_LOG_APP_ARCHIVE_V2 ( FMODIFYBILLID );


 EXEC P_ALTERPK 'PK_T_LOG_APP_OTHER', 'T_LOG_APP_OTHER', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGV2_OTHER_OPTIMEUSER') CREATE INDEX IDX_LOGV2_OTHER_OPTIMEUSER ON T_LOG_APP_OTHER ( FOPTIME ,FBIZAPPID ,FUSERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGV2_OTHER_MODIFYBILLID') CREATE INDEX IDX_LOGV2_OTHER_MODIFYBILLID ON T_LOG_APP_OTHER ( FMODIFYBILLID );




