除了id(我已经设置为pk)之外,如何在表中插入值而不指定所有列名?
xytpbqjk1#
如果你的 id 是自动递增的,如果您插入 NULL . 因此,您可以执行以下操作:
id
NULL
create table t ( id int auto_increment primary key, x int ); insert into t select null, 2; insert into t select null, 3;
也就是说,我建议(几乎)总是包含 insert . 所以我强烈建议:
insert
insert into t (x) select 2; insert into t (x) select 3;
1条答案
按热度按时间xytpbqjk1#
如果你的
id
是自动递增的,如果您插入NULL
. 因此,您可以执行以下操作:也就是说,我建议(几乎)总是包含
insert
. 所以我强烈建议: