Toad World® Forums

Extra key for PK not nessesary but can't be deleted. Why and how?

When I create a table there is automatically a PK without having an attribute linked to it. The first thing I create is an INTEGER, NN, Unique id field and adding it to my PK. The strange thing is, that in keys there is another key with the name of my id field, but it doesn’t actually is needed for anything. Why can I not delete it? Why does it exist anyway? Is there a better way to add an ID field to a fresh table?

Hi Erik,

if you wish to create just PK, don’t check the Unique checkbox. The Unique checkbox should be used for non-PK attributes that need to have unique values. If you check this checkbox, TDM creates new alternate key for you - this should be a timesaver.

To quickly create new PK, add new attribute to your entity, Apply and double click area in PK column. Red key appears there and your attribute becomes NN automatically. The only thing that you need to change is data type.

FYI: In Settings | Options you can allow attributes in keys to be nullable. Click Settings | Options and navigate to section Physical Model. There is checkbox Allow Null Attributes in Keys. If this checkbox is activated, you need to manually set NN settings.