Mittwoch, 25. Juni 2014

Renaming primary keys in the logical model of Oracles Data Modeler

In the past I explained already how to rename inheritance relations. Now I will show a small script to fix wrong names of primary key constraints. This is necessary, if an entity gets renamed. In this case the primary key constraint has still the old name of the entity according to the naming convention, which was active when the primary key has been created.

entities = model.getEntitySet().toArray();
for (var e = 0; e < entities.length; e++) {
  entity = entities[e];
  entity_name = entity.getName();
  primarykey = entity.getPK();
  primarykey_name = primarykey.getName();
  new_primarykey_name = entity_name.toUpperCase() + "_PK";
  if (primarykey_name != new_primarykey_name) {

This script works on the logical model and sets all primary key names to the upper case of the entity name followed by "_PK".

Keine Kommentare: