SQLite:将表从一个数据库复制到另一个数据库的最简单方法? [英] SQLite: Easiest way to copy a table from one database to another?

查看:64
本文介绍了SQLite:将表从一个数据库复制到另一个数据库的最简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个sqlite数据库,想从A库复制一张表到B库,A库的其他表不应该复制.在 Java 中最简单的方法是什么?

I have two sqlite databases and want to copy a table from database A to database B. The other tables in database A should not be copied. What is the easiest way to do that in Java?

我可以明确地做一些类似 Select * from A 的事情,然后将所有这些插入到数据库 B 中,但不应该有更好的方法吗?

I could definitively do something like Select * from A and then insert all of this into database B, but shouldn't there a better way?

推荐答案

打开要从中复制的数据库,然后运行此代码以附加要复制到的数据库,然后复制表.

Open the database you are copying from, then run this code to attach the database you are copying to and then copy a table over.

ATTACH DATABASE 'other.db' AS other;

INSERT INTO other.tbl
SELECT * FROM main.tbl;

这篇关于SQLite:将表从一个数据库复制到另一个数据库的最简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆