I have created a table in my database and added a few constraints. When i use the DESC keyword on my table, depending on what constraints I placed, the Key column changes its record.
Here's the table definition:
CREATE TABLE t(
sif INT,
sif2 INT NOT NULL,
sif3 INT UNIQUE,
sif4 INT NOT NULL UNIQUE
);
and Here's the DESC result:
mysql> desc t;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| sif | int(11) | YES | | NULL | |
| sif2 | int(11) | NO | | NULL | |
| sif3 | int(11) | YES | UNI | NULL | |
| sif4 | int(11) | NO | PRI | NULL | |
+-------+---------+------+-----+---------+-------+
4 rows in set (0.01 sec)
Why did my column sif4 get the key value PRI? I never mentioned a primary key definition and yet the DESC keyword shows that the column is set up as a primary key.