Skip to main content

How to enable primary keys for the populated tables?

  • August 3, 2017
  • 1 reply
  • 7 views

nkarkare

When I created the tables and the constraints, I forgot to do the following:

ALTER DATABASE warehouse SET EnableNewPrimaryKeysByDefault = 1;
ALTER DATABASE warehouse SET EnableNewUniqueKeysByDefault = 1;

Now I have populated the tables, how can I enforce the primary keys without staring over?

1 reply

drlove
Forum|alt.badge.img
  • Participating Frequently
  • August 3, 2017

You can enable a constraint on an already populated table with ALTER TABLE. The constraint would be enforced for current content as well as content you add to the table later.