/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TM_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_TM_DEPOSIT_ACCESS', 'T_TM_DEPOSIT_ACCESS', 'FENTRYID', '0';

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


 EXEC P_ALTERPK 'PK_T_TM_DEPOSIT_RATE', 'T_TM_DEPOSIT_RATE', 'FENTRYID', '0';

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


 EXEC P_ALTERPK 'PK_T_TM_TRADE_C', 'T_TM_TRADE_C', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'INDEX_T_TM_TRADE_C') CREATE  CLUSTERED INDEX INDEX_T_TM_TRADE_C ON T_TM_TRADE_C ( FRATETYPE );


 EXEC P_ALTERPK 'PK_T_TM_TRADE', 'T_TM_TRADE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'PK_TM_TRADE_BILLNO') CREATE INDEX PK_TM_TRADE_BILLNO ON T_TM_TRADE ( FBILLNO );


 EXEC P_ALTERPK 'PK_T_TM_TRADE_L', 'T_TM_TRADE_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_TM_TRADE_SWC', 'T_TM_TRADE_SWC', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_TRADE_SWC') CREATE INDEX IDX_TM_TRADE_SWC ON T_TM_TRADE_SWC ( FID ,FBASEDATAID );


 EXEC P_ALTERPK 'PK_T_TM_TRADE_WC', 'T_TM_TRADE_WC', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_TRADE_WC') CREATE INDEX IDX_TM_TRADE_WC ON T_TM_TRADE_WC ( FID ,FBASEDATAID );


 EXEC P_ALTERPK 'PK_T_TM_LOWRISK', 'T_TM_LOWRISK', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_LOWRISK') CREATE INDEX IDX_TM_LOWRISK ON T_TM_LOWRISK ( FBILLNO );


 EXEC P_ALTERPK 'PK_T_TM_LOWRISK_ENTRYS', 'T_TM_LOWRISK_ENTRYS', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_TM_LOWRISK_L', 'T_TM_LOWRISK_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_TM_OPTIONCOMB', 'T_TM_OPTIONCOMB', 'FID', '0';

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


 EXEC P_ALTERPK 'PK_T_TM_OPTIONCOMB_ENTRY', 'T_TM_OPTIONCOMB_ENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_TM_STRUCTDEPOSIT_O', 'T_TM_STRUCTDEPOSIT_O', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_STRUCTDEPOSIT_O') CREATE INDEX IDX_TM_STRUCTDEPOSIT_O ON T_TM_STRUCTDEPOSIT_O ( FID ,FOBSDATE );


 EXEC P_ALTERPK 'PK_T_TM_STRUCTDEPOSIT_WC', 'T_TM_STRUCTDEPOSIT_WC', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_STRUCTDEPOSIT_WC') CREATE INDEX IDX_TM_STRUCTDEPOSIT_WC ON T_TM_STRUCTDEPOSIT_WC ( FID ,FBASEDATAID );


 EXEC P_ALTERPK 'PK_T_TM_STRUCTDEPOSIT_Z', 'T_TM_STRUCTDEPOSIT_Z', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_TM_TRADE_D', 'T_TM_TRADE_D', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_STRUCTDEPOSIT') CREATE INDEX IDX_TM_STRUCTDEPOSIT ON T_TM_TRADE_D ( FHOOKTYPE ,FHOOKMARK );


 EXEC P_ALTERPK 'PK_T_TM_TRADE_R', 'T_TM_TRADE_R', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'T_TM_TRADE_R_I') CREATE  CLUSTERED INDEX T_TM_TRADE_R_I ON T_TM_TRADE_R ( FSWAPTYPE );


 EXEC P_ALTERPK 'PK_T_TM_TRADE_S', 'T_TM_TRADE_S', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'T_TM_TRADE_S_L') CREATE  CLUSTERED INDEX T_TM_TRADE_S_L ON T_TM_TRADE_S ( FRATETYPE );


 EXEC P_ALTERPK 'PK_T_TM_TRADE_P', 'T_TM_TRADE_P', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TRADE_P') CREATE INDEX IDX_TRADE_P ON T_TM_TRADE_P ( FPAYBANKACCTID );


 EXEC P_ALTERPK 'PK_T_TM_TRADE_O', 'T_TM_TRADE_O', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'INDEX_TM_TRADEOPTIONS_I') CREATE INDEX INDEX_TM_TRADEOPTIONS_I ON T_TM_TRADE_O ( FEXDATE );


 EXEC P_ALTERPK 'PK_T_TM_TRADE_F', 'T_TM_TRADE_F', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_TRADE_F') CREATE INDEX IDX_TM_TRADE_F ON T_TM_TRADE_F ( FTRADETYPE );


 EXEC P_ALTERPK 'PK_T_TM_CASHFLOW', 'T_TM_CASHFLOW', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_CASHFLOW') CREATE INDEX IDX_TM_CASHFLOW ON T_TM_CASHFLOW ( FBILLNO ,FBILLSTATUS );


 EXEC P_ALTERPK 'PK_T_TM_CASHFLOW_BAK', 'T_TM_CASHFLOW_BAK', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_CF_BAK') CREATE INDEX IDX_TM_CF_BAK ON T_TM_CASHFLOW_BAK ( FBILLNO ,FBILLSTATUS );


 EXEC P_ALTERPK 'PK_T_TM_CASHFLOW_ENTRYS', 'T_TM_CASHFLOW_ENTRYS', 'FENTRYID', '0';

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


 EXEC P_ALTERPK 'PK_T_TM_CASHFLOW_ENTRYS_BAK', 'T_TM_CASHFLOW_ENTRYS_BAK', 'FENTRYID', '0';

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


 EXEC P_ALTERPK 'PK_T_TM_BUSINESSBILL', 'T_TM_BUSINESSBILL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'PK_TM_BUSINESSBILL_BILLNO') CREATE INDEX PK_TM_BUSINESSBILL_BILLNO ON T_TM_BUSINESSBILL ( FBILLNO );


 EXEC P_ALTERPK 'PK_T_TM_BUSINESSBILL_E', 'T_TM_BUSINESSBILL_E', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'PK_TM_BUSINESSBILL_BANK') CREATE INDEX PK_TM_BUSINESSBILL_BANK ON T_TM_BUSINESSBILL_E ( FPAYBANKID );


 EXEC P_ALTERPK 'PK_T_TM_BUSINESSBILL_L', 'T_TM_BUSINESSBILL_L', 'FPKID', '1';

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



 EXEC P_ALTERPK 'PK_T_TM_TRADE_B', 'T_TM_TRADE_B', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_TM_TRADE_B') CREATE INDEX IDX_T_TM_TRADE_B ON T_TM_TRADE_B ( FBONDISSUEID );


 EXEC P_ALTERPK 'PK_T_TM_BONDISSUE', 'T_TM_BONDISSUE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_BONDISSUE') CREATE INDEX IDX_TM_BONDISSUE ON T_TM_BONDISSUE ( FBILLNO ,FBILLSTATUS );


 EXEC P_ALTERPK 'PK_T_TM_BONDISSUE_E', 'T_TM_BONDISSUE_E', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TM_BONDISSUE_E') CREATE INDEX IDX_TM_BONDISSUE_E ON T_TM_BONDISSUE_E ( FISSTUB ,FISANNUITY ,FISAMORT2ACCRET );


 EXEC P_ALTERPK 'PK_T_TM_BONDISSUE_ENTRYS', 'T_TM_BONDISSUE_ENTRYS', 'FENTRYID', '0';

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


 EXEC P_ALTERPK 'PK_T_TM_BONDISSUE_INDEXWC', 'T_TM_BONDISSUE_INDEXWC', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_TM_BONDISSUE_L', 'T_TM_BONDISSUE_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_TM_BONDISSUE_WC', 'T_TM_BONDISSUE_WC', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_TM_APPHOME_ENTRY', 'T_TM_APPHOME_ENTRY', 'FENTRYID', '0';

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


 EXEC P_ALTERPK 'PK_T_TM_APPHOME_SETTING', 'T_TM_APPHOME_SETTING', 'FID', '0';

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


 EXEC P_ALTERPK 'PK_T_TM_APPHOME_SETTING_L', 'T_TM_APPHOME_SETTING_L', 'FPKID', '0';

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



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TM_constraint.sql **/
