/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\HPDI_constraint.sql **/
 EXEC P_ALTERPK 'PK_HPDI_OPTPL', 'T_HPDI_OPTPL', 'FID', '1';

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


 EXEC P_ALTERPK 'PK_HPDI_OPTPLENT', 'T_HPDI_OPTPLENT', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HPDI_OPTPLENT') CREATE INDEX IDX_HPDI_OPTPLENT ON T_HPDI_OPTPLENT ( FOPERATIONID );


 EXEC P_ALTERPK 'PK_HPDI_OPPKG', 'T_HPDI_OPPKG', 'FID', '1';

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


 EXEC P_ALTERPK 'PK_HPDI_OPPKG_L', 'T_HPDI_OPPKG_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_HPDI_OPPKGENT', 'T_HPDI_OPPKGENT', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HPDI_OPPKGENT') CREATE INDEX IDX_HPDI_OPPKGENT ON T_HPDI_OPPKGENT ( FOPERATIONID );


 EXEC P_ALTERPK 'PK_HPDI_OPPKGUSEREG', 'T_HPDI_OPPKGUSEREG', 'FUSEORGID,FDATAID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HPDI_OPPKGUSEREG') CREATE INDEX IDX_HPDI_OPPKGUSEREG ON T_HPDI_OPPKGUSEREG ( FCREATEORGID );


 EXEC P_ALTERPK 'PK_HPDI_OPPKGEXC', 'T_HPDI_OPPKGEXC', 'FDATAID,FUSEORGID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HPDI_OPPKGEXC') CREATE INDEX IDX_HPDI_OPPKGEXC ON T_HPDI_OPPKGEXC ( FCREATEORGID );


 EXEC P_ALTERPK 'PK_HPDI_OPTPLUSEREG', 'T_HPDI_OPTPLUSEREG', 'FUSEORGID,FDATAID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HPDI_OPTPLUSEREG') CREATE INDEX IDX_HPDI_OPTPLUSEREG ON T_HPDI_OPTPLUSEREG ( FCREATEORGID );


 EXEC P_ALTERPK 'PK_HPDI_OPTPLEXC', 'T_HPDI_OPTPLEXC', 'FDATAID,FUSEORGID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HPDI_OPTPLEXC') CREATE INDEX IDX_HPDI_OPTPLEXC ON T_HPDI_OPTPLEXC ( FCREATEORGID );

/** PK_HPDI_HPDI_OPTPL_L 改为  PK_HPDI_OPTPL_L； PDM已经是PK_HPDI_OPTPL_L了，老早的表，这个表也不会再被使用，这个脚本直接改一下主键名，这样脚本扫描则能通过。 **/
 EXEC P_ALTERPK 'PK_HPDI_OPTPL_L', 'T_HPDI_OPTPL_L', 'FPKID', '1';

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



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