For example, you export apple.db
to backup.sql
with .dump
or .schema
as shown below. *backup.sql
is created if it doesn't exist and .dump
can export schema with data and .schema
can export only schema and my answer explains how to export a database:
sqlite3 apple.db .dump > backup.sql
Or:
sqlite3 apple.db .schema > backup.sql
Now, you can import backup.sql
into orange.db
as shown below. *orange.db
is created if it doesn't exist:
sqlite3 orange.db < backup.sql
Or:
sqlite3 orange.db
...
sqlite> .read backup.sql
Be careful, if you directly import apple.db
into orange.db
as shown below:
sqlite3 orange.db < apple.db
Or:
sqlite3 orange.db
...
sqlite> .read apple.db
Then, you get the error below:
Parse error near line 1: near "SQLite": syntax error