附加数据库
sqlite可以对多个数据库(多个文件)进行操作
代码语言:javascript复制sqlite> .databases
seq name file
--- --------------- ----------------------------------------------------------
0 main /usr/local/sqlite3.11/bin/test.db
sqlite>
sqlite> attach database 'test_tmp.db' as 'abc';
sqlite> .databases
seq name file
--- --------------- ----------------------------------------------------------
0 main /usr/local/sqlite3.11/bin/test.db
2 abc /usr/local/sqlite3.11/bin/test_tmp.db
sqlite> .tables
abc.test test
sqlite> select * from abc.test;
1|hello
2|hello
3|hello
4|hello
5|hello
sqlite> select * from test;
1|hello
2|hello
3|hello
4|hello
5|hello
sqlite> create table t2(id int primary key not null, name text );
sqlite> .tables
abc.test t2 test
sqlite> create table abc.t2(id int primary key not null, name text );
sqlite> .tables
abc.t2 abc.test t2 test
sqlite>
sqlite> INSERT INTO abc.t2 VALUES(1,'hello');
sqlite> INSERT INTO abc.t2 VALUES(3,'hello');
sqlite> INSERT INTO abc.t2 VALUES(5,'hello');
sqlite>
sqlite> INSERT INTO t2 VALUES(2,'hello');
sqlite> INSERT INTO t2 VALUES(4,'hello');
sqlite> select * from abc.t2;
1|hello
3|hello
5|hello
sqlite> select * from t2;
2|hello
4|hello
sqlite>