unique的列可以多次插入空值?
root@b test>CREATE TABLE tb5_1( id SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, username VARCHAR(100) UNIQUE KEY, age TINYINT UNSIGNED );
Query OK, 0 rows affected (0.16 sec)
root@b test>SHOW COLUMNS FROM tb5_1;
+----------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------------------+------+-----+---------+----------------+
| id | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| username | varchar(100) | YES | UNI | NULL | |
| age | tinyint(3) unsigned | YES | | NULL | |
+----------+----------------------+------+-----+---------+----------------+
3 rows in set (0.05 sec)
root@b test>INSERT tb5_1(username,age) VALUES(NULL,21);
Query OK, 1 row affected (0.03 sec)
root@b test>INSERT tb5_1(username,age) VALUES(NULL,22);
Query OK, 1 row affected (0.06 sec)
root@b test>SELECT * FROM tb5_1;
+----+----------+------+
| id | username | age |
+----+----------+------+
| 1 | NULL | 21 |
| 2 | NULL | 22 |
+----+----------+------+
2 rows in set (0.08 sec)