SQLite inserta solo la clave principal
Frecuentes
Visto 2,028 equipos
2
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!
2 Respuestas
3
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
2
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 sqlite insert primary-key auto-increment or haz tu propia pregunta.