          old_db_name_len,
                       id_len - old_db_name_len));
               END IF;
               UPDATE SYS_FOREIGN
                SET ID = new_foreign_id
                WHERE ID = foreign_id;
               UPDATE SYS_FOREIGN_COLS
                SET ID = new_foreign_id
                WHERE ID = foreign_id;
        END IF;
       END IF;
END LOOP;
UPDATE SYS_FOREIGN SET REF_NAME = :new_table_name
WHERE REF_NAME = :old_table_name
  AND TO_BINARY(REF_NAME)
    = TO_BINARY(:old_table_name);
END;
