1

please help me for: how to copy all tables in sqlite's database from one database to another using c++

I have a database file,I want to copy all table to another database and using c++ language,I don't know how to Loop read all table in the original database an how to copy them to another database using c++.

2

1 Answer 1

0

You can just create a copy of the database file with the new database name, that is assuming you want all the data as well. This can be done without connecting to/opening the database by standard File handling.

  • The database name is only significant as the file name.

Another way is to use VACUUM INTO 'file'; again this copies all data, this does require the database to have been connected as the above is an SQL statement.

  • e.g. VACUUM INTO 'E:\Navicat\SQlite Databases\myOtherDBName'; (Windows)
  • see VACUUM

If you don't want the data then when connected to the new database you can delete the rows in all the tables followed by a VACUUM (if you wish). This would probably be best done within a transaction.

Sign up to request clarification or add additional context in comments.

2 Comments

But I need using c++ to finish it
@JiangKai either can be done in c++ (or many languages).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.