如果db具有primary字段,如何将N个SQLite数据库文件合并为一个? [英] How to merge N SQLite database files into one if db has the primary field?
本文介绍了如果db具有primary字段,如何将N个SQLite数据库文件合并为一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一堆SQLite数据库文件,我需要将它们合并为一个大数据库文件.
I have a bunch of SQLite db files, and I need to merge them into one big db files.
- 我该怎么办?
基于此,我猜是那些三个命令应将两个数据库合并为一个.
Based on this, I guess those three commands should merge two db into one.
attach './abc2.db' as toMerge;
insert into test select * from toMerge.test
detach database toMerge
问题是数据库具有PRIMARY KEY字段,并且我收到此消息-错误:PRIMARY KEY必须唯一".
The problem is the db has PRIMARY KEY field, and I got this message - "Error: PRIMARY KEY must be unique".
这是数据库的测试表.
This is the test table for the db.
CREATE TABLE test (id integer PRIMARY KEY AUTOINCREMENT,value text,goody text)
推荐答案
我不确定100%,但是似乎我应该阅读所有元素并将元素(除PRIMARY KEY以外)一一插入到新的数据库.
I'm not 100% sure, but it seems that I should read all the elements and insert the element (except the PRIMARY KEY) one by one into the new data base.
这篇关于如果db具有primary字段,如何将N个SQLite数据库文件合并为一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文