DECLARE
   tabelaExists NUMBER; 
   itemExists NUMBER;
   column_exists exception;
   pragma exception_init (column_exists , -01430);
BEGIN
   itemExists := 0;
   SELECT COUNT(CONSTRAINT_NAME) INTO itemExists 
     FROM ALL_CONSTRAINTS
     WHERE UPPER(CONSTRAINT_NAME) = UPPER('TIPO_EVENTO_EXTRA_FORMAPAGO_FK');

   IF itemExists > 0 THEN
     EXECUTE IMMEDIATE 'ALTER TABLE TIPO_EVENTO_EXTRA_FORMAPAGO DROP CONSTRAINT TIPO_EVENTO_EXTRA_FORMAPAGO_FK';
   END IF;
   
   SELECT COUNT(TABLE_NAME) INTO tabelaExists 
     FROM ALL_TABLES
     WHERE UPPER(TABLE_NAME) = UPPER('TIPO_EVENTO_EXTRA_FORMAPAGO'); 
   IF itemExists > 0 THEN  
      EXECUTE IMMEDIATE 'ALTER TABLE TIPO_EVENTO_EXTRA_FORMAPAGO ADD CONSTRAINT TIPO_EVENTO_EXTRA_FORMAPAGO_FK FOREIGN KEY (FORMAPAGO_ID) REFERENCES FORMA_PAGO (FORMAPAGO_ID)';
   END IF;   
   exception when column_exists then null;
END;