views:

18

answers:

1

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.

+3  A: 
values (NULL, "heart", "heart_shape.jpg", now());
Col. Shrapnel