将自动递增的值添加到具有一列的表中 [英] Adding auto-incremented values to a table with one column
问题描述
我需要创建一个基本上只保留索引列表的表.因此,我创建了一个表,其中只有一个自动递增的列,称为"id".但是,我似乎无法向该表隐式添加自动递增的值.
I need to create a table that basically keeps a list of indices only. Therefore I've created a table with just one, auto-incremented column called 'id'. However, I can't seem to implicitly add auto-incremented values to this table.
我知道通常在表中有这样一列(不仅有此列)时,您都可以这样做:
I know that usually when you have such a column in a table (with more than just this column) you can do:
插入表(col1,col2 ...)值(val1,val2 ...)
INSERT INTO TABLE (col1, col2 ...) VALUES (val1, val2 ...)
如果您不指定自动递增的列,它将自动获取一个值.但是,像这样的东西:
And if you don't specify the auto-incremented column, it would automatically get a value. However, things like:
插入表()值() 插入表 插入表()
INSERT INTO TABLE () VALUES () INSERT INTO TABLE INSERT INTO TABLE ()
等都在我的单列表上产生错误.谁能提供解决方案? 谢谢.
etc. all produce an error on my single-columned table. Can anyone offer a solution? Thanks.
p.s.我正在使用Sqlite,以防万一.
p.s. I'm using Sqlite, in case it matters.
推荐答案
尝试以下操作:
INSERT INTO YOUR_TABLE(YOUR_ID) VALUES (NULL);
这篇关于将自动递增的值添加到具有一列的表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!