/* 旧版管理员功能启用开关 表索引 */
EXEC P_ALTERPK 'PK_T_PERM_OLDADMINENABLE', 'T_PERM_OLDADMINENABLE', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PERM_OLDADMINENABLE') CREATE INDEX IDX_PERM_OLDADMINENABLE ON T_PERM_OLDADMINENABLE ( FMODIFIERID );

/* 管理员组类型 表索引 */
EXEC P_ALTERPK 'PK_T_SEC_USERGROUPTYPE', 'T_SEC_USERGROUPTYPE', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SEC_USERGROUPTYPE') CREATE INDEX IDX_SEC_USERGROUPTYPE ON T_SEC_USERGROUPTYPE ( FNUMBER );

/* 管理员组类型(多语言) 表索引 */
EXEC P_ALTERPK 'PK_T_SEC_USERGROUPTYPE_L', 'T_SEC_USERGROUPTYPE_L', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SEC_USERGROUPTYPE_L') CREATE INDEX IDX_SEC_USERGROUPTYPE_L ON T_SEC_USERGROUPTYPE_L ( FID ,FLOCALEID );

/* 管理员组扩展信息 表索引 */
EXEC P_ALTERPK 'PK_T_SEC_USERGROUP_P', 'T_SEC_USERGROUP_P', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_SEC_USERGROUP_P') CREATE INDEX IDX_SEC_USERGROUP_P ON T_SEC_USERGROUP_P ( FADMINSCHEME ,FADMINTYPE );
 
/* 管理员业务单元管辖范围 表索引 */
EXEC P_ALTERPK 'PK_T_PERM_ADMINGROUPBIZUNIT', 'T_PERM_ADMINGROUPBIZUNIT', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PERM_ADMINGRPBIZUNIT') CREATE INDEX IDX_PERM_ADMINGRPBIZUNIT ON T_PERM_ADMINGROUPBIZUNIT ( FUSERGROUPID ,FORGID );

/* 管理员行政组织管辖范围 表索引 */
EXEC P_ALTERPK 'PK_T_PERM_ADMINGROUPORG', 'T_PERM_ADMINGROUPORG', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PERM_ADMINGROUPORG') CREATE INDEX IDX_PERM_ADMINGROUPORG ON T_PERM_ADMINGROUPORG ( FUSERGROUPID ,FORGID );

/* 管理员应用管辖范围 表索引 */
EXEC P_ALTERPK 'PK_T_PERM_ADMINGROUPAPP', 'T_PERM_ADMINGROUPAPP', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ADMINGROUPAPP') CREATE INDEX IDX_ADMINGROUPAPP ON T_PERM_ADMINGROUPAPP ( FAPPID ,FUSERGROUPID );

/* 管理员行政组织管辖范围额外用户 表索引 */
EXEC P_ALTERPK 'PK_T_PERM_ADMINGROUPADDUSER', 'T_PERM_ADMINGROUPADDUSER', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PERM_ADMINGRPADDUSER') CREATE INDEX IDX_PERM_ADMINGRPADDUSER ON T_PERM_ADMINGROUPADDUSER ( FUSERID ,FUSERGROUPID );

/* 管理员系统服务云管辖范围 表索引 */
EXEC P_ALTERPK 'PK_T_PERM_ADMINGROUPFUNPERM', 'T_PERM_ADMINGROUPFUNPERM', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PERM_ADMINGRPFUNPERM') CREATE INDEX IDX_PERM_ADMINGRPFUNPERM ON T_PERM_ADMINGROUPFUNPERM ( FAPPID ,FENTITYNUM ,FPERMITEMID );