SQLite inserta solo la clave principal

I have a table that is only a single column, INTEGER PRIMARY KEY.

As it's an autoincrement, How do I insert a value?

He tratado

INSERT INTO Rule DEFAULT VALUES;

which runs but doesn't actually insert anything. any other ideas?

¡Gracias!

preguntado el 12 de febrero de 14 a las 05:02

2 Respuestas

The following command creates a column named INTEGER with no type:

> CREATE TABLE wrong(INTEGER PRIMARY KEY);
> INSERT INTO wrong DEFAULT VALUES;
> INSERT INTO wrong DEFAULT VALUES;
> SELECT * FROM wrong;
INTEGER
----------
 
 

If you don't forget the column name, DEFAULT VALUES works just fine with an INTEGER PRIMARY KEY column:

> CREATE TABLE Rule(RuleID INTEGER PRIMARY KEY);
> INSERT INTO Rule DEFAULT VALUES;
> INSERT INTO Rule DEFAULT VALUES;
> SELECT * FROM Rule;
RuleID
----------
1
2

Respondido 12 Feb 14, 09:02

Insertar un null:

sqlite> create table a(a integer primary key autoincrement);
sqlite> insert into a values(null);
sqlite> insert into a values(null);
sqlite> select * from a;
1
2

Respondido 12 Feb 14, 07:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.