主键默认值是否可以为NULL?为什么这样描述? [英] Can a primary key default be NULL? Why is it described as such?
本文介绍了主键默认值是否可以为NULL?为什么这样描述?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表,当我描述
它是:
I have a table that when I describe
it is:
mysql> DESC my_table;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| contact_id | int(11) | NO | PRI | NULL | auto_increment |
| location | varchar(20) | YES | | NULL | |
| city | varchar(20) | YES | | NULL | |
| state | varchar(2) | YES | | NULL | |
+------------+-------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
我的问题是:为什么主键 contact_id
默认
显示为 NULL
?
我为列创建了 NOT NULL
主键
不能 NULL
。
如何 Null
be $
和默认
为 NULL
?
My question is: why for the primary key contact_id
the Default
is displayed as NULL
?
I created the table with NOT NULL
for the column and the Primary Key
can not be NULL
anyway.
How can Null
be NO
and Default
be NULL
?
推荐答案
它不能为null的事实使得默认列的内容不相关。他们在默认列中使用null,否则将需要另一个魔术值来表示不相关,未使用,结束。
The fact that it can't be null makes the content of the 'default' column irrelevant. They are using 'null' in the 'default' column because otherwise they would need another magic value to indicate 'irrelevant', 'unused', end.
担心。
这篇关于主键默认值是否可以为NULL?为什么这样描述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文