Toad World® Forums

Auto name PK in modeler 5.3

Is there a way to make 5.3 modeler to auto name PK?


Hello Lepa,

I'm not sure if you mean automatic naming of new PKs or automatic renaming of all current PKs, so I will describe both methods.

  • Automatic naming of newly created keys using Default Values
    Go to Settings Menu | Default Values | expand the Entities node | Keys. You cannot set the default name for PKs only, but you are able to set the default name for any new keys. Edit the value of Name/Caption to whatever you want. Note that you can use the Application Variables on the right side.

Let's say I want to name new PKs like this: <TableCaption>_PK. I'll just edit the Name/Caption values and use the Application Variable OwnerCaption and add "_PK" at the end. Once I do that, I'll confirm the changes and restart TDM.

When I create a new key, its default name is going to be <TableCaption>_PK. The disadvantage of this method is that this default name will apply to all keys you will create, such as FKs, AKs...

  • Renaming all existing PKs using a Macro
    Another approach is to create your PKs and then rename them at once using Macro. If you want to rename only some of your PKs, select the entities where they are located. If you want to rename all of your PKs, don't select anything. Then go to the Macros Menu | Rename and choose the Rename Primary Keys macro. This will rename selected/all PKs to PK_.