/**Begin D:\datamodel\pdm\PDM_UPGRADE_1.3\PDM_UPGRADE_1.3\PDM_UPGRADE\log\0515\RIM_constraint.sql **/
 EXEC P_ALTERPK 'PK_RIM_INVOICE_UNCHECK', 'T_RIM_INVOICE_UNCHECK', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE_UNCHECK') CREATE  CLUSTERED INDEX IDX_RIM_INVOICE_UNCHECK ON T_RIM_INVOICE_UNCHECK ( FTENANT_NO ,FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INVOICE_FILE', 'T_RIM_INVOICE_FILE', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE_FILE') CREATE UNIQUE  CLUSTERED INDEX IDX_RIM_INVOICE_FILE ON T_RIM_INVOICE_FILE ( FTENANT_NO ,FSERIAL_NO );


 EXEC P_ALTERPK 'PK_RIM_SELECT_ACCOUNT', 'T_RIM_SELECT_ACCOUNT', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_SELECT_ACCOUNT') CREATE  CLUSTERED INDEX IDX_RIM_SELECT_ACCOUNT ON T_RIM_SELECT_ACCOUNT ( FINVOICE_CODE ,FINVOICE_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_SELECT_ACCOUNT_STATUS') CREATE INDEX IDX_RIM_SELECT_ACCOUNT_STATUS ON T_RIM_SELECT_ACCOUNT ( FHANDLE_STATUS );


 EXEC P_ALTERPK 'PK_RIM_INVOICE_HIS', 'T_RIM_INVOICE_HIS', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE_HIS') CREATE  CLUSTERED INDEX IDX_RIM_INVOICE_HIS ON T_RIM_INVOICE_HIS ( FDATA_TABLE ,FDATA_PK );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE_HIS2') CREATE INDEX IDX_RIM_INVOICE_HIS2 ON T_RIM_INVOICE_HIS ( FTRACEID );


 EXEC P_ALTERPK 'PK_RIM_INV_COLLECT_ORG', 'T_RIM_INV_COLLECT_ORG', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_COLLECT_ORG') CREATE  CLUSTERED INDEX IDX_RIM_INV_COLLECT_ORG ON T_RIM_INV_COLLECT_ORG ( FCOLLECT_ORG );

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


 EXEC P_ALTERPK 'PK_RIM_INV_COLLECT_USER', 'T_RIM_INV_COLLECT_USER', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_COLLECT_USER') CREATE  CLUSTERED INDEX IDX_RIM_INV_COLLECT_USER ON T_RIM_INV_COLLECT_USER ( FCOLLECT_USER );

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


 EXEC P_ALTERPK 'PK_RIM_INVOICE_SUM', 'T_RIM_INVOICE_SUM', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE_SUM') CREATE  CLUSTERED INDEX IDX_RIM_INVOICE_SUM ON T_RIM_INVOICE_SUM ( FCREATE_DATE );


 EXEC P_ALTERPK 'PK_RIM_INV_AIR_ITEM', 'T_RIM_INV_AIR_ITEM', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_AIR_ITEM_FK') CREATE  CLUSTERED INDEX IDX_RIM_INV_AIR_ITEM_FK ON T_RIM_INV_AIR_ITEM ( FID );


 EXEC P_ALTERPK 'PK_RIM_INV_AIR', 'T_RIM_INV_AIR', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_AIR') CREATE  CLUSTERED INDEX IDX_RIM_INV_AIR ON T_RIM_INV_AIR ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_AIR_NO') CREATE INDEX IDX_RIM_INV_AIR_NO ON T_RIM_INV_AIR ( FPRINT_NUM ,FETICKET_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_CUSTOM', 'T_RIM_INV_CUSTOM', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_RIM_INV_CUSTOM') CREATE  CLUSTERED INDEX IDX_T_RIM_INV_CUSTOM ON T_RIM_INV_CUSTOM ( FSERIAL_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_CUSTOM_ITEM', 'T_RIM_INV_CUSTOM_ITEM', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_CUSTOM_ITEM_FK') CREATE  CLUSTERED INDEX IDX_RIM_INV_CUSTOM_ITEM_FK ON T_RIM_INV_CUSTOM_ITEM ( FID );


 EXEC P_ALTERPK 'PK_RIM_INV_GENERAL', 'T_RIM_INV_GENERAL', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_GENERAL') CREATE  CLUSTERED INDEX IDX_RIM_INV_GENERAL ON T_RIM_INV_GENERAL ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_GENERAL_NO') CREATE INDEX IDX_RIM_INV_GENERAL_NO ON T_RIM_INV_GENERAL ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_MOTOR', 'T_RIM_INV_MOTOR', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_MOTOR') CREATE  CLUSTERED INDEX IDX_RIM_INV_MOTOR ON T_RIM_INV_MOTOR ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_MOTOR_NO') CREATE UNIQUE INDEX IDX_RIM_INV_MOTOR_NO ON T_RIM_INV_MOTOR ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_ORDINARY', 'T_RIM_INV_ORDINARY', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_ORDINARY') CREATE  CLUSTERED INDEX IDX_RIM_INV_ORDINARY ON T_RIM_INV_ORDINARY ( FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_ORDINARY_NO') CREATE UNIQUE INDEX IDX_RIM_INV_ORDINARY_NO ON T_RIM_INV_ORDINARY ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_ORDINARY_ITEM', 'T_RIM_INV_ORDINARY_ITEM', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_ORDINARY_ITEM_FK') CREATE  CLUSTERED INDEX IDX_RIM_INV_ORDINARY_ITEM_FK ON T_RIM_INV_ORDINARY_ITEM ( FID );


 EXEC P_ALTERPK 'PK_RIM_INV_OTHER', 'T_RIM_INV_OTHER', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_OTHER') CREATE  CLUSTERED INDEX IDX_RIM_INV_OTHER ON T_RIM_INV_OTHER ( FSERIAL_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_QUOTA', 'T_RIM_INV_QUOTA', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_QUOTA') CREATE  CLUSTERED INDEX IDX_RIM_INV_QUOTA ON T_RIM_INV_QUOTA ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_QUOTA_NO') CREATE INDEX IDX_RIM_INV_QUOTA_NO ON T_RIM_INV_QUOTA ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_SPECIAL', 'T_RIM_INV_SPECIAL', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_SPECIAL') CREATE  CLUSTERED INDEX IDX_RIM_INV_SPECIAL ON T_RIM_INV_SPECIAL ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_SPECIAL_NO') CREATE UNIQUE INDEX IDX_RIM_INV_SPECIAL_NO ON T_RIM_INV_SPECIAL ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_SPECIAL_ITEM', 'T_RIM_INV_SPECIAL_ITEM', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_SPECIAL_ITEM_FK') CREATE  CLUSTERED INDEX IDX_RIM_INV_SPECIAL_ITEM_FK ON T_RIM_INV_SPECIAL_ITEM ( FID );


 EXEC P_ALTERPK 'PK_RIM_INV_TAX_PROOF', 'T_RIM_INV_TAX_PROOF', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TAX_PROOF') CREATE  CLUSTERED INDEX IDX_RIM_INV_TAX_PROOF ON T_RIM_INV_TAX_PROOF ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TAX_PROOF_NO') CREATE UNIQUE INDEX IDX_RIM_INV_TAX_PROOF_NO ON T_RIM_INV_TAX_PROOF ( FTAX_PAID_PROOF_NO ,FTAX_AUTHORITY_NAME );


 EXEC P_ALTERPK 'PK_RIM_INV_TAXI', 'T_RIM_INV_TAXI', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TAXI') CREATE  CLUSTERED INDEX IDX_RIM_INV_TAXI ON T_RIM_INV_TAXI ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TAXI_NO') CREATE UNIQUE INDEX IDX_RIM_INV_TAXI_NO ON T_RIM_INV_TAXI ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_TOLL', 'T_RIM_INV_TOLL', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TOLL') CREATE  CLUSTERED INDEX IDX_RIM_INV_TOLL ON T_RIM_INV_TOLL ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TOLL_NO') CREATE UNIQUE INDEX IDX_RIM_INV_TOLL_NO ON T_RIM_INV_TOLL ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_TOLL_ITEM', 'T_RIM_INV_TOLL_ITEM', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TOLL_ITEM_FK') CREATE  CLUSTERED INDEX IDX_RIM_INV_TOLL_ITEM_FK ON T_RIM_INV_TOLL_ITEM ( FID );


 EXEC P_ALTERPK 'PK_RIM_INV_TRAIN', 'T_RIM_INV_TRAIN', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TRAIN') CREATE  CLUSTERED INDEX IDX_RIM_INV_TRAIN ON T_RIM_INV_TRAIN ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TRAIN_NO') CREATE INDEX IDX_RIM_INV_TRAIN_NO ON T_RIM_INV_TRAIN ( FTRAIN_NUM ,FSEQUENCE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_TRANSPORT', 'T_RIM_INV_TRANSPORT', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TRANSPORT') CREATE  CLUSTERED INDEX IDX_RIM_INV_TRANSPORT ON T_RIM_INV_TRANSPORT ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_TRANSPORT_NO') CREATE INDEX IDX_RIM_INV_TRANSPORT_NO ON T_RIM_INV_TRANSPORT ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INV_USEDCAR', 'T_RIM_INV_USEDCAR', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_USEDCAR') CREATE  CLUSTERED INDEX IDX_RIM_INV_USEDCAR ON T_RIM_INV_USEDCAR ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INV_USEDCAR_NO') CREATE UNIQUE INDEX IDX_RIM_INV_USEDCAR_NO ON T_RIM_INV_USEDCAR ( FINVOICE_CODE ,FINVOICE_NO );


 EXEC P_ALTERPK 'PK_RIM_INVOICE', 'T_RIM_INVOICE', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE') CREATE  CLUSTERED INDEX IDX_RIM_INVOICE ON T_RIM_INVOICE ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE_TYPE') CREATE INDEX IDX_RIM_INVOICE_TYPE ON T_RIM_INVOICE ( FINVOICE_TYPE );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE_CODE') CREATE INDEX IDX_RIM_INVOICE_CODE ON T_RIM_INVOICE ( FINVOICE_CODE ,FINVOICE_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_INVOICE_BUYER') CREATE INDEX IDX_RIM_INVOICE_BUYER ON T_RIM_INVOICE ( FBUYER_TAX_NO );


 EXEC P_ALTERPK 'PK_RIM_EXPENSE', 'T_RIM_EXPENSE', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_EXPENSE') CREATE  CLUSTERED INDEX IDX_RIM_EXPENSE ON T_RIM_EXPENSE ( FEXPENSE_ID );


 EXEC P_ALTERPK 'PK_RIM_VERIFY', 'T_RIM_VERIFY', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_VERIFY_NAME') CREATE  CLUSTERED INDEX IDX_RIM_VERIFY_NAME ON T_RIM_VERIFY ( FNAME );


 EXEC P_ALTERPK 'PK_RIM_VERIFY_ENTRY', 'T_RIM_VERIFY_ENTRY', 'FENTRYID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_VERIFY_ENTRY_FK') CREATE  CLUSTERED INDEX IDX_RIM_VERIFY_ENTRY_FK ON T_RIM_VERIFY_ENTRY ( FID );


 EXEC P_ALTERPK 'PK_RIM_VOUCH_RELATION', 'T_RIM_VOUCH_RELATION', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_VOUCH_RELATION') CREATE  CLUSTERED INDEX IDX_RIM_VOUCH_RELATION ON T_RIM_VOUCH_RELATION ( FBILL_TYPE ,FVOUCH_ID );


 EXEC P_ALTERPK 'PK_RIM_VOUCH', 'T_RIM_VOUCH', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_VOUCH') CREATE  CLUSTERED INDEX IDX_RIM_VOUCH ON T_RIM_VOUCH ( FVOUCH_NO );


 EXEC P_ALTERPK 'PK_RIM_EXPENSE_RELATION', 'T_RIM_EXPENSE_RELATION', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_EXPENSE_RELATION') CREATE  CLUSTERED INDEX IDX_RIM_EXPENSE_RELATION ON T_RIM_EXPENSE_RELATION ( FSERIAL_NO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_EXPENSE_RELATION2') CREATE INDEX IDX_RIM_EXPENSE_RELATION2 ON T_RIM_EXPENSE_RELATION ( FEXPENSE_ID ,FRESOURCE );


 EXEC P_ALTERPK 'PK_RIM_COVER_RELATION', 'T_RIM_COVER_RELATION', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_COVER_RELATION') CREATE  CLUSTERED INDEX IDX_RIM_COVER_RELATION ON T_RIM_COVER_RELATION ( FEXPENSE_ID ,FRESOURCE );


 EXEC P_ALTERPK 'PK_RIM_COVER', 'T_RIM_COVER', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_COVER') CREATE  CLUSTERED INDEX IDX_RIM_COVER ON T_RIM_COVER ( FCOVER_NO ,FRESOURCE );

 EXEC P_ALTERPK 'PK_RIM_ATTACH', 'T_RIM_ATTACH', 'FID', '0';
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_ATTACH') CREATE  CLUSTERED INDEX IDX_RIM_ATTACH ON T_RIM_ATTACH ( FATTACH_NO );


 EXEC P_ALTERPK 'PK_RIM_ATTACH_RELATION', 'T_RIM_ATTACH_RELATION', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_RIM_ATTACH_RELATION') CREATE  CLUSTERED INDEX IDX_RIM_ATTACH_RELATION ON T_RIM_ATTACH_RELATION ( FRELATION_TYPE ,FRELATION_ID );


/**End D:\datamodel\pdm\PDM_UPGRADE_1.3\PDM_UPGRADE_1.3\PDM_UPGRADE\log\0515\RIM_constraint.sql **/
