SQLite: Easiest way to copy a table from one database to another?

前端 未结 2 1771
误落风尘
误落风尘 2021-01-01 20:58

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 i

相关标签:
2条回答
  • 2021-01-01 21:06

    Why do you want to do that in Java? You can do it directly at the command-line, by dumping your table, and reading it into your other database :

    sqlite3 A.sqlite ".dump some_table" | sqlite3 B.sqlite
    
    0 讨论(0)
  • 2021-01-01 21:26

    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;
    
    0 讨论(0)
提交回复
热议问题