I read that Primary key should be Unique and not null. Now when I create a table checking
with depid
as primary key, the table description says this according to me : the Null
column value NO
indicates that depid
can't be Null
but at the same time the Default
column value Null
says that default is Null
mysql> desc checking;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| depid | int(11) | NO | PRI | NULL | |
| deppp | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
2 rows in set (0.05 sec)
mysql> insert into checking values(1,2);
Query OK, 1 row affected (0.12 sec)
mysql> insert into checking(deppp) values(1);
ERROR 1364 (HY000): Field 'depid' doesn't have a default value
If that is the case why is the last query producing an error?
Edit The error got resolved once primary key column is labelled as Auto Increment
. But that still doesn't explain why the Default
column shows Null
for a primary key column.