
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LOG_LOGIN') 
 CREATE TABLE T_LOG_LOGIN (
FID BIGINT DEFAULT 0 NOT NULL,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBIZAPPNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORGNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPDATE DATETIME,
FCLIENTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCLIENTIP VARCHAR(256) DEFAULT ' ' NOT NULL,
FARCHIVETIME DATETIME,
FOPNAME NVARCHAR(256) DEFAULT ' ' NOT NULL,
FOPDESC NVARCHAR(256) DEFAULT ' ' NOT NULL,
FCLIENTNAME NVARCHAR(256) DEFAULT ' ' NOT NULL,
FEXTENDFIELD1 VARCHAR(256) DEFAULT ' ' NOT NULL,
FEXTENDFIELD2 VARCHAR(256) DEFAULT ' ' NOT NULL,
FEXTENDFIELD3 VARCHAR(256) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LOG_ADMIN_OPERATION') 
 CREATE TABLE T_LOG_ADMIN_OPERATION (
FID BIGINT DEFAULT 0 NOT NULL,
FUSERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FOPNAME NVARCHAR(256) DEFAULT ' ' NOT NULL,
FBIZAPPID BIGINT DEFAULT 0 NOT NULL,
FBIZOBJID BIGINT DEFAULT 0 NOT NULL,
FBIZOBJNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZAPPNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORGNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPDATE DATETIME,
FCLIENTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCLIENTIP VARCHAR(256) DEFAULT ' ' NOT NULL,
FARCHIVETIME DATETIME,
FOPDESC NVARCHAR(256) DEFAULT ' ' NOT NULL,
FCLIENTNAME NVARCHAR(256) DEFAULT ' ' NOT NULL,
FUSERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXTENDFIELD1 VARCHAR(256) DEFAULT ' ' NOT NULL,
FEXTENDFIELD2 VARCHAR(256) DEFAULT ' ' NOT NULL,
FEXTENDFIELD3 VARCHAR(256) DEFAULT ' ' NOT NULL,
FMODIFYBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODIFYCONTENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMODIFYCONTENT_TAG NCLOB,
FMODIFYFIELDS NVARCHAR(1020) DEFAULT ' ' NOT NULL,
FMODIFYBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL
);


 EXEC P_ALTERPK 'PK_T_LOG_LOGIN', 'T_LOG_LOGIN', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_LOGIN_OPDATE') CREATE INDEX IDX_T_LOG_LOGIN_OPDATE ON T_LOG_LOGIN ( FOPDATE ,FBIZAPPID ,FUSERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_LOGIN_USERNAME') CREATE INDEX IDX_T_LOG_LOGIN_USERNAME ON T_LOG_LOGIN ( FUSERNAME );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_LOGIN_CLIENTNAME') CREATE INDEX IDX_T_LOG_LOGIN_CLIENTNAME ON T_LOG_LOGIN ( FCLIENTNAME );


 EXEC P_ALTERPK 'PK_T_LOG_ADMIN_OPERATION', 'T_LOG_ADMIN_OPERATION', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_LOGIN_ADMIN_OPDATE') CREATE INDEX IDX_T_LOG_LOGIN_ADMIN_OPDATE ON T_LOG_ADMIN_OPERATION ( FOPDATE ,FUSERID ,FBIZAPPID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_LOGIN_ADMIN_UTYPE') CREATE INDEX IDX_T_LOG_LOGIN_ADMIN_UTYPE ON T_LOG_ADMIN_OPERATION ( FUSERTYPE );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_LOGIN_ADMIN_CTYPE') CREATE INDEX IDX_T_LOG_LOGIN_ADMIN_CTYPE ON T_LOG_ADMIN_OPERATION ( FCLIENTTYPE );

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


