
 EXEC P_ALTERPK 'PK_PERM_LOG_USER', 'T_PERM_LOG_USER', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FPERM_LOGID') CREATE INDEX IDX_FPERM_LOGID ON T_PERM_LOG_USER ( FPERM_LOGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_USERNAME') CREATE INDEX IDX_USERNAME ON T_PERM_LOG_USER ( FUSER_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG', 'T_PERM_LOG', 'FID,FNUMBER', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FOPER_TIME') CREATE INDEX IDX_FOPER_TIME ON T_PERM_LOG ( FOPER_TIME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_FUNCPERM', 'T_PERM_LOG_DIFF_FUNCPERM', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY') CREATE INDEX IDX_LOGID_ENTITY ON T_PERM_LOG_DIFF_FUNCPERM ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_FIELDPERM', 'T_PERM_LOG_DIFF_FIELDPERM', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY2') CREATE INDEX IDX_LOGID_ENTITY2 ON T_PERM_LOG_DIFF_FIELDPERM ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_NEWDR', 'T_PERM_LOG_DIFF_NEWDR', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY3') CREATE INDEX IDX_LOGID_ENTITY3 ON T_PERM_LOG_DIFF_NEWDR ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_NEWDRPROP', 'T_PERM_LOG_DIFF_NEWDRPROP', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY4') CREATE INDEX IDX_LOGID_ENTITY4 ON T_PERM_LOG_DIFF_NEWDRPROP ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DIMUSER', 'T_PERM_LOG_DIFF_DIMUSER', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIMUSER') CREATE INDEX IDX_LOGID_DIMUSER ON T_PERM_LOG_DIFF_DIMUSER ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_COMMROLE', 'T_PERM_LOG_DIFF_COMMROLE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY_A') CREATE INDEX IDX_LOGID_ENTITY_A ON T_PERM_LOG_DIFF_COMMROLE ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_BCPERM', 'T_PERM_LOG_DIFF_BCPERM', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY_B') CREATE INDEX IDX_LOGID_ENTITY_B ON T_PERM_LOG_DIFF_BCPERM ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DISPERM', 'T_PERM_LOG_DIFF_DISPERM', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY_C') CREATE INDEX IDX_LOGID_ENTITY_C ON T_PERM_LOG_DIFF_DISPERM ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DIMRANGE', 'T_PERM_LOG_DIFF_DIMRANGE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIMRANGE') CREATE INDEX IDX_LOGID_DIMRANGE ON T_PERM_LOG_DIFF_DIMRANGE ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_USER', 'T_PERM_LOG_DIFF_USER', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIFFUSER') CREATE INDEX IDX_LOGID_DIFFUSER ON T_PERM_LOG_DIFF_USER ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DIMFUNC', 'T_PERM_LOG_DIFF_DIMFUNC', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIMFUNC') CREATE INDEX IDX_LOGID_DIMFUNC ON T_PERM_LOG_DIFF_DIMFUNC ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DIMFIELD', 'T_PERM_LOG_DIFF_DIMFIELD', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIMFIELD') CREATE INDEX IDX_LOGID_DIMFIELD ON T_PERM_LOG_DIFF_DIMFIELD ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DIMNEWDR', 'T_PERM_LOG_DIFF_DIMNEWDR', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIMNEWDR') CREATE INDEX IDX_LOGID_DIMNEWDR ON T_PERM_LOG_DIFF_DIMNEWDR ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DIMNEWDRP', 'T_PERM_LOG_DIFF_DIMNEWDRP', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIMNEWDRP') CREATE INDEX IDX_LOGID_DIMNEWDRP ON T_PERM_LOG_DIFF_DIMNEWDRP ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DIMDIS', 'T_PERM_LOG_DIFF_DIMDIS', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIMDIS') CREATE INDEX IDX_LOGID_DIMDIS ON T_PERM_LOG_DIFF_DIMDIS ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DIMROLE', 'T_PERM_LOG_DIFF_DIMROLE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_DIMROLE') CREATE INDEX IDX_LOGID_DIMROLE ON T_PERM_LOG_DIFF_DIMROLE ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_BUSIROLE', 'T_PERM_LOG_DIFF_BUSIROLE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_BUSIROLE') CREATE INDEX IDX_LOGID_BUSIROLE ON T_PERM_LOG_DIFF_BUSIROLE ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_COPYTARUSER', 'T_PERM_LOG_COPYTARUSER', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_COPYTARUSER') CREATE INDEX IDX_LOGID_COPYTARUSER ON T_PERM_LOG_COPYTARUSER ( FPERM_LOGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_UNAME') CREATE INDEX IDX_UNAME ON T_PERM_LOG_COPYTARUSER ( FUSER_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_BUSIUNIT', 'T_PERM_LOG_DIFF_BUSIUNIT', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_BUSIUNIT') CREATE INDEX IDX_LOGID_BUSIUNIT ON T_PERM_LOG_DIFF_BUSIUNIT ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_ADMORG', 'T_PERM_LOG_DIFF_ADMORG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ADMORG') CREATE INDEX IDX_LOGID_ADMORG ON T_PERM_LOG_DIFF_ADMORG ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_APP', 'T_PERM_LOG_DIFF_APP', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_APP') CREATE INDEX IDX_LOGID_APP ON T_PERM_LOG_DIFF_APP ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_ADMORGUSR', 'T_PERM_LOG_DIFF_ADMORGUSR', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ADMORGUSR') CREATE INDEX IDX_LOGID_ADMORGUSR ON T_PERM_LOG_DIFF_ADMORGUSR ( FPERM_LOGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_UNAME_ADMORGUSR') CREATE INDEX IDX_UNAME_ADMORGUSR ON T_PERM_LOG_DIFF_ADMORGUSR ( FUSER_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_OPRINFO', 'T_PERM_LOG_DIFF_OPRINFO', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY_OPRINFO') CREATE INDEX IDX_LOGID_ENTITY_OPRINFO ON T_PERM_LOG_DIFF_OPRINFO ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_OPRDIRECT', 'T_PERM_LOG_DIFF_OPRDIRECT', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_OPRDIRECT') CREATE INDEX IDX_LOGID_OPRDIRECT ON T_PERM_LOG_DIFF_OPRDIRECT ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_OPREXUSR', 'T_PERM_LOG_DIFF_OPREXUSR', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_OPREXUSR') CREATE INDEX IDX_LOGID_OPREXUSR ON T_PERM_LOG_DIFF_OPREXUSR ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_OPREXUSGR', 'T_PERM_LOG_DIFF_OPREXUSGR', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_OPREXUSGR') CREATE INDEX IDX_LOGID_OPREXUSGR ON T_PERM_LOG_DIFF_OPREXUSGR ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_OPREXROLE', 'T_PERM_LOG_DIFF_OPREXROLE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_OPREXROLE') CREATE INDEX IDX_LOGID_OPREXROLE ON T_PERM_LOG_DIFF_OPREXROLE ( FPERM_LOGID );


 EXEC P_ALTERPK 'PK_T_PERM_LOG_DIFF_FAILMSG', 'T_PERM_LOG_DIFF_FAILMSG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PERMLOGDIFF_CREATETIME') CREATE INDEX IDX_PERMLOGDIFF_CREATETIME ON T_PERM_LOG_DIFF_FAILMSG ( FCREATETIME );


 EXEC P_ALTERPK 'PK_PERM_LOG_DIFF_DRINFO', 'T_PERM_LOG_DIFF_DRINFO', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_LOGID_ENTITY_DRINFO') CREATE INDEX IDX_LOGID_ENTITY_DRINFO ON T_PERM_LOG_DIFF_DRINFO ( FPERM_LOGID ,FENTITY_NAME );


 EXEC P_ALTERPK 'PK_PERM_LOG_ARCHIVE', 'T_PERM_LOG_ARCHIVE', 'FID,FNUMBER', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PL_ARCH_OPTIME') CREATE INDEX IDX_PL_ARCH_OPTIME ON T_PERM_LOG_ARCHIVE ( FOPER_TIME );


 EXEC P_ALTERPK 'PK_T_BDLOG_SETTING', 'T_BDLOG_SETTING', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BDLOG_SETTING_LOGTYPE') CREATE UNIQUE INDEX IDX_BDLOG_SETTING_LOGTYPE ON T_BDLOG_SETTING ( FLOG_TYPE );


 EXEC P_ALTERPK 'PK_T_BDLOG_INDEX', 'T_BDLOG_INDEX', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BDLOG_NAME') CREATE INDEX IDX_BDLOG_NAME ON T_BDLOG_INDEX ( FNAME );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BDLOG_LOGTYPE') CREATE UNIQUE  CLUSTERED INDEX IDX_BDLOG_LOGTYPE ON T_BDLOG_INDEX ( FLOG_TYPE );


 EXEC P_ALTERPK 'PK_T_BDLOG_FAILMSG', 'T_BDLOG_FAILMSG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CREATETIME') CREATE INDEX IDX_CREATETIME ON T_BDLOG_FAILMSG ( FCREATETIME );

 