开发者

"Warn on null primary keys" table design option in SSMS

开发者 https://www.devze.com 2023-01-19 10:20 出处:网络
I SSMS (2008R2) menu Tools --> Options --> Designers --> Table and Database Designers --> \"Warn on null primary keys\"

I SSMS (2008R2) menu Tools --> Options --> Designers --> Table and Database Designers --> "Warn on null primary keys" I played checking and unchecking this checkbox but could not detect the differences.

What is it for?

My related questions, probably:

  • NULL permitted in Primary Key - why and in which DBMS?
  • 开发者_开发知识库Why to use “not null primary key” in TSQL?


OK, it would seem that when this is checked, if any of the columns are nullable, it will produce a warning stating

Primary Key cannot be created on Column 'X' because it allows null values.

Clear the Allow Nulls check box for each column in the primary key.

Whereas if this is not check, and you make columns the primary key, they will automatically be changed to non nullable.

0

精彩评论

暂无评论...
验证码 换一张
取 消