Can the default primary key be NULL? Why is this described as such?

I have a table when I do describethis:

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)  

My question is: why is it contact_id Defaultdisplayed for the primary key as NULL?
I created a table with NOT NULLfor a column, but Primary Keyin any case it cannot be NULL.
How to NULLbe NOand Defaultbe NULL?

+5
source share
3 answers

, , "default" . "null" "default", , "", "", .

.

+4

NOT NULL MySQL , , . contact_id "" Null. Default . contact_id . , Null.

+2

, (NULL) , . , (NULL):

  • SQL :

  • SQL , : Defaut

  • SQL , : NULL

  • SQL , null: , , , " "

, .

0
source

All Articles