Data Migration

Migration Using the Shells
Supported Data and Schema

If you have a database created by SQLite, you can migrate it to a Berkeley DB database for use with the BDB SQL interface. For production applications, you should do this only when your application is shutdown.

Migration Using the Shells

To migrate your data from SQLite to a Berkeley DB database:

  1. Make sure your application is shutdown.

  2. Open the SQLite database within the sqlite3 shell.

  3. Execute the .output command to specify the location where you want to dump data.

  4. Dump the database using the SQLite .dump command.

  5. Close the sqlite3 shell and open the Berkeley DB dbsql shell. Note that if you build the BDB SQL interface with the compatibility option, you can alternatively use Berkeley DB's sqlite3 utility.

  6. Load the dumped data using the .read command.

Note that you can migrate in the reverse direction as well. Dump the Berkeley DB database by calling .dump from within the dbsql shell, and load it into SQLite by calling .read from within SQLite's sqlite3 shell.

Supported Data and Schema

You can migrate data between SQLite and Berkeley DB that uses the UTF-8 character encoding.

The following data types can be migrated between SQLite and Berkeley DB:

  • CHAR, TEXT , VARCHAR, NVARCHAR, STRING

  • REAL, DOUBLE, FLOAT

  • INTEGER, BOOLEAN, BIG INTEGER, NUMBER

  • NUMERIC

  • BLOB, CLOB

  • NULL, NOT NULL

  • COLLATE BINARY, COLLATE RTRIM, COLLATE NOCASE

  • DATETIME, CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP

The following schema can be migrated between SQLite and Berkeley DB:

  • PRAGMA writable_schema=ON/OFF

  • PRAGMA foreign_keys=ON/OFF

  • PRAGMA cache_size

  • CREATE TABLE

    • PRIMARY KEY

    • UNIQUE

    • CONFLICT IGNORE, FAIL, REPLACE, ABORT, ROOLBACK

    • REFERENCE ON ... CASECADE, ON ... NO ACTION, DEFERRABLE INITIALLY DEFERRED, and so forth.

    • AUTOINCREMENT

    • Static DEFAULT value, dynamic DEFAULT value

    • Functions such as datetime, typeof, and so forth.

    • ASC, DESC

    • HIDDEN

    • CHECK

  • CREATE INDEX, UNIQUE INDEX

  • CREATE VIEW

    • SELECT statement, ANALYZE

    • JOIN

    • UNION

  • CREATE TRIGGER AFTER/BEFORE BEGIN

  • CREATE VIRTUAL TABLE USING

  • INSERT