How to skip all the column names in MySQL when the table has auto increment primary key?
- by Jian Lin
A table is:
mysql> desc gifts;
+---------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+----------------+
| giftID | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(80) | YES | | NULL | |
| filename | varchar(80) | YES | | NULL | |
| effectiveTime | datetime | YES | | NULL | |
+---------------+-------------+------+-----+---------+----------------+
the following is ok:
mysql> insert into gifts
-> values (10, "heart", "heart_shape.jpg", now());
Query OK, 1 row affected (0.05 sec)
but is there a way to not specify the "10"... and just let each one be 11, 12, 13... ?
I can do it using
mysql> insert into gifts (name, filename, effectiveTime)
-> values ("coffee", "coffee123.jpg", now());
Query OK, 1 row affected (0.00 sec)
but the column names need to be all specified. Is there a way that they don't have to be specified and the auto increment of primary key still works? thanks.