2010-09-09 27 views

回答

5

你并不需要设置IDENTITY INSERT保持的ID,因为它总是能够明确设置值。使用SQLite,你可以插入ROWID列:

drop table test; 
create table test(name varchar); 
insert into test(name) values('Hello'); 
insert into test(rowid, name) values(10, 'World'); 
select rowid, name from test; 

同样的,如果你使用自动增量主键:

drop table test; 
create table test(id integer primary key autoincrement, name varchar); 
insert into test(name) values('Hello'); 
insert into test values(10, 'World'); 
select * from test; 

又见http://www.sqlite.org/autoinc.html

+0

十分感谢,进出口使用System.Data .Sqlite与c#中的实体框架一起使用,因此它为我生成sql,它不能包含该列!屁股! – 2010-09-11 11:32:31