/**Begin D:\PDM_UPGRADE\PDM1\BOS_constraint.sql **/

 EXEC P_ALTERPK 'PK_T_CTSY_TENANT', 'T_CTSY_TENANT', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_CTSY_TENANT_FNUMBER') CREATE INDEX IDX_T_CTSY_TENANT_FNUMBER ON T_CTSY_TENANT ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_CTSY_TENANT_L', 'T_CTSY_TENANT_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_CTSY_TENANT_L_FID') CREATE INDEX IDX_T_CTSY_TENANT_L_FID ON T_CTSY_TENANT_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_CTSY_BASEDATA', 'T_CTSY_BASEDATA', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_CTSY_BASEDATA_FNUMBER') CREATE INDEX IDX_T_CTSY_BASEDATA_FNUMBER ON T_CTSY_BASEDATA ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_CTSY_BASEDATA_L', 'T_CTSY_BASEDATA_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_CTSY_BASEDATA_L_FID') CREATE INDEX IDX_T_CTSY_BASEDATA_L_FID ON T_CTSY_BASEDATA_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_CTSY_DISTRIBUTSCHEME', 'T_CTSY_DISTRIBUTSCHEME', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_CTSY_DISTRIBUTSCHEME_NUM') CREATE INDEX IDX_T_CTSY_DISTRIBUTSCHEME_NUM ON T_CTSY_DISTRIBUTSCHEME ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_CTSY_DISTRIBUTSCHEME_L', 'T_CTSY_DISTRIBUTSCHEME_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CTSY_DISTRIBUTSCHEME_L_FID') CREATE INDEX IDX_CTSY_DISTRIBUTSCHEME_L_FID ON T_CTSY_DISTRIBUTSCHEME_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_CTSY_TENANTORGRELATION', 'T_CTSY_TENANTORGRELATION', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CTSY_TENORGREL_TYPETENORG') CREATE INDEX IDX_CTSY_TENORGREL_TYPETENORG ON T_CTSY_TENANTORGRELATION ( FTYPE ,FTENANTID ,FORGID );


 EXEC P_ALTERPK 'PK_T_CTSY_DISTSCHEMETENANTS', 'T_CTSY_DISTSCHEMETENANTS', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CTSY_DISTSCHEMETENANTS_FID') CREATE INDEX IDX_CTSY_DISTSCHEMETENANTS_FID ON T_CTSY_DISTSCHEMETENANTS ( FID );


 EXEC P_ALTERPK 'PK_T_CTSY_DISTSCHEMEFILTERS', 'T_CTSY_DISTSCHEMEFILTERS', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CTSY_DISTSCHEMEFILTERS_FID') CREATE INDEX IDX_CTSY_DISTSCHEMEFILTERS_FID ON T_CTSY_DISTSCHEMEFILTERS ( FID );


 EXEC P_ALTERPK 'PK_T_CTSY_DISTTRIGGERS', 'T_CTSY_DISTTRIGGERS', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CTSY_DISTTRIGGERS_TENANTID') CREATE INDEX IDX_CTSY_DISTTRIGGERS_TENANTID ON T_CTSY_DISTTRIGGERS ( FDISTID ,FTENANTID ,FISCDATAID );



/**End D:\PDM_UPGRADE\PDM1\BOS_constraint.sql **/
