YJM YAN <jming....@gmail.com> wrote:
> source table:
> DDL:
>     "create table xxx_table(id interger primary key autoincrement, field1,
> field2)"
> 
> int ret = sqlite3_exec(m_db,"attach './backup.db' as filedb",0,0,NULL);
> ret = sqlite3_exec(m_db,"begin transaction",0,0,NULL);
> ret = sqlite3_exec(m_db,"create table filedb.xxx_table as select * from
> xxx_table",0,0,NULL);
> ret = sqlite3_exec(m_db,"commit transaction",0,0,NULL);
> ret = sqlite3_exec(m_db,"detach filedb",0,0,NULL);
> 
> destination table:
> DDL:
>     "create table xxx_table(id interger , field1, field2)"
> 
> use this way to back up a table, lost the primary key property.
> 
> How to configure its?

Instead of "create table as select", run a separate CREATE TABLE statement to 
create the new table the way you want it. Then run INSERT ... SELECT statement 
to copy the data over.
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to