/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDL_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_DM_DICTTABLEREF', 'T_DM_DICTTABLEREF', 'FTABLENAME,FREFTABLENAME', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_DICTTABLEREF' AND KSQL_INDNAME = 'IDX_DM_DICTTABLEREF_TIMESTAMP') CREATE INDEX IDX_DM_DICTTABLEREF_TIMESTAMP ON T_DM_DICTTABLEREF ( FTIMESTAMP );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_DICTTABLEREF' AND KSQL_INDNAME = 'IDX_DM_DICTTABLEREF_REFTABLE') CREATE INDEX IDX_DM_DICTTABLEREF_REFTABLE ON T_DM_DICTTABLEREF ( FREFTABLENAME );


 EXEC P_ALTERPK 'PK_T_DM_DICTCOLUMN', 'T_DM_DICTCOLUMN', 'FTABLENAME,FCOLUMNNAME', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_DICTCOLUMN' AND KSQL_INDNAME = 'IDX_DM_DICTCOLUMN_COMMENT') CREATE INDEX IDX_DM_DICTCOLUMN_COMMENT ON T_DM_DICTCOLUMN ( FCOMMENT );


 EXEC P_ALTERPK 'PK_T_DM_DICTINDEX', 'T_DM_DICTINDEX', 'FTABLENAME,FINDEXNAME', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_DICTINDEX' AND KSQL_INDNAME = 'IDX_DM_DICTINDEX_TIMESTAMP') CREATE INDEX IDX_DM_DICTINDEX_TIMESTAMP ON T_DM_DICTINDEX ( FTIMESTAMP );


 EXEC P_ALTERPK 'PK_T_DM_DICTTABLE', 'T_DM_DICTTABLE', 'FTABLENAME', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_DICTTABLE' AND KSQL_INDNAME = 'IDX_DM_DICTTABLE_TIMESTAMP') CREATE INDEX IDX_DM_DICTTABLE_TIMESTAMP ON T_DM_DICTTABLE ( FTIMESTAMP );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_DICTTABLE' AND KSQL_INDNAME = 'IDX_DM_DICTTABLE_APP') CREATE INDEX IDX_DM_DICTTABLE_APP ON T_DM_DICTTABLE ( FAPPNUMBER );


 EXEC P_ALTERPK 'PK_T_DM_PDMDIAGRAM_D', 'T_DM_PDMDIAGRAM_D', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_PDMDIAGRAM_D' AND KSQL_INDNAME = 'IDX_DM_PDMDIAGRAM_D_NUMBER') CREATE UNIQUE INDEX IDX_DM_PDMDIAGRAM_D_NUMBER ON T_DM_PDMDIAGRAM_D ( FNUMBER ,FBIZAPPID ,FPRODUCT ,FISV );


 EXEC P_ALTERPK 'PK_T_DM_PDMDIAGRAM_M', 'T_DM_PDMDIAGRAM_M', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_PDMDIAGRAM_M' AND KSQL_INDNAME = 'IDX_DM_PDMDIAGRAM_M_NUMBER') CREATE UNIQUE INDEX IDX_DM_PDMDIAGRAM_M_NUMBER ON T_DM_PDMDIAGRAM_M ( FNUMBER ,FBIZAPPID ,FPRODUCT ,FISV );


 EXEC P_ALTERPK 'PK_T_DM_PDMMODEL_D', 'T_DM_PDMMODEL_D', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_PDMMODEL_D' AND KSQL_INDNAME = 'IDX_DM_PDMMODEL_D_NUMBER') CREATE UNIQUE INDEX IDX_DM_PDMMODEL_D_NUMBER ON T_DM_PDMMODEL_D ( FNUMBER ,FBIZAPPID ,FPRODUCT ,FISV ,FCREATOR );


 EXEC P_ALTERPK 'PK_T_DM_PDMMODEL_M', 'T_DM_PDMMODEL_M', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_DM_PDMMODEL_M' AND KSQL_INDNAME = 'IDX_DM_PDMMODEL_M_NUMBER') CREATE UNIQUE INDEX IDX_DM_PDMMODEL_M_NUMBER ON T_DM_PDMMODEL_M ( FNUMBER ,FBIZAPPID ,FPRODUCT ,FISV );



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