如何在只有一个自动增量列的表中插入一行?

时间:2023-02-03 14:13:02

My table has only a single column calld id. This column is an autoincrementing key (I am using it for sequencing). I want to do something like: insert into sequencer; but this gives me SQL errors because I guess I need to have a values portion. But there are no other columns in the table and I want the id column to be autoincremented. I'd also rather not hack this by just adding another dummy column. Thanks.

我的表只有一个列calld id。此列是自动增量键(我将其用于测序)。我想做一些事情:插入音序器;但这给了我SQL错误,因为我想我需要有一个值部分。但是表中没有其他列,我希望自动增加id列。我也不想通过添加另一个虚拟列来破解它。谢谢。

1 个解决方案

#1


10  

INSERT INTO table SET id = NULL;

or

INSERT INTO table VALUES (NULL);

When inserting NULL into an auto-increment column, mysql will generate a new number instead.

将NULL插入自动增量列时,mysql将生成一个新数字。

#1


10  

INSERT INTO table SET id = NULL;

or

INSERT INTO table VALUES (NULL);

When inserting NULL into an auto-increment column, mysql will generate a new number instead.

将NULL插入自动增量列时,mysql将生成一个新数字。