How to Copy DB2 Tables into SQLite
Step 1: Connect to DB2
Host, port (50000), database and user on the Source DB tab - DB2 needs its client driver, and the driver version decides which authentication DB2 will accept.
Step 2: Open the SQLite file
On the Target DB tab: a path, not a server. The .db file is created if it does not exist, which is also why the target has no schema dropdown - one file, one namespace.
The Type Map Is the Whole Job
DB2 is a typed, server-side database; SQLite has five storage classes and no enforcement. That gap is where a copy either works or quietly changes the data:
| In DB2 | In SQLite |
|---|---|
DECIMAL(18,4), NUMERIC | NUMERIC affinity; an exact decimal read as a number passes through a double and loses digits past 15, so exact money belongs in a text column |
TIMESTAMP | stored as text; the format decides whether comparisons and sorts still work - ISO 8601 is the one that sorts correctly as a string |
DATE, TIME | text, same rule |
CLOB | TEXT - fine, but a CLOB over 1 GB is a value SQLite stores whole and reads whole |
BLOB, DBCLOB | BLOB; a DBCLOB holds double-byte characters, so it belongs in TEXT |
GRAPHIC, VARGRAPHIC | TEXT with UTF-8 - the conversion happens here, and a missing one produces two-byte mojibake |
SMALLINT, INTEGER, BIGINT | INTEGER (SQLite's is 64-bit) - a DB2 BIGINT fits |
IDENTITY | no such thing: copy the values into an INTEGER PRIMARY KEY, or let SQLite assign rowids and accept new ids |
Two of these are worth deciding before the first run, not after: money as text (exact) or as a number (fast, lossy past 15 digits), and timestamps as ISO text so that ORDER BY on the column is chronological rather than alphabetical.
DB2 Writes Its Names in Capitals
An unquoted create table employees in DB2 becomes EMPLOYEES, and the schema is part of the name (HR.EMPLOYEES). Two consequences for a copy:
- The table list is upper case; a filter written as
employeesfinds nothing. - SQLite has no schemas inside the file - everything lands in
main, so two DB2 schemas with a table of the same name collide on the second copy. Name the target table explicitly (HR_EMPLOYEES) or copy them one at a time.
The same upper-case rule applies to DB2's own catalogue queries: SYSCAT.TABLES, SYSCAT.COLUMNS - which is where you look when a column list has to be checked before mapping.
Copy, Migrate or Sync
Three words, one screen, different intents:
- Copy - a table or a query into a new table in the
.dbfile. The one-off. - Migrate - every table of a schema, in dependency order, usually followed by a check that the row counts match.
- Sync - the same copy on a schedule with update on a key, so the file tracks the DB2 table instead of accumulating every version of it.
What none of them is: replication. There is no log reading and no trigger - the file is as current as the last run, which is exactly what a scheduled sync with a row count in the log is for.
DB2 to SQLite — Quick Facts
- Source
- DB2 for LUW (port 50000) - the driver is required on the client machine
- Target
- a SQLite
.db/.sqlitefile, created on first use - Modes
- create, append, or refresh on a key column
- Type map
DECIMALto text or numeric,TIMESTAMPto ISO text,DBCLOB/GRAPHICto UTF-8 text- Names
- DB2 identifiers are upper case; SQLite has one schema (
main) - CLI
- the saved task runs without a window - one command, one log
Common Pitfalls when Copying DB2 into SQLite
- Money as a number:
DECIMAL(18,4)in a SQLite column ofNUMERICaffinity goes through a binary floating point when it is read as a number - keep it as text if the cents matter. - Timestamps as text:
2024-03-15 08:30:00.123456sorts correctly only if every row uses the same format; a mix ofDD.MM.YYYYand ISO does not. - Two schemas, one table name: SQLite has one namespace, so the second copy overwrites the first unless the target names differ.
IDENTITYcolumns: copying the values keeps the ids, letting SQLite assign new ones breaks every foreign key that pointed at the old numbers.- A CLOB of a gigabyte: SQLite stores and reads the value whole - large objects belong on disk with a path in the row.
- Appending twice: SQLite enforces the primary key, so a re-run either fails on the duplicates or doubles them, depending on the mode - refresh on a key is the mode that repeats safely.
Which Searches Land Here
| What you searched | Meaning | Page |
|---|---|---|
| db2 to sqlite, copy db2 table to sqlite, migrate db2 to sqlite, sync db2 data to sqlite, convert db2 to sqlite | this page | you are on it |
| db2 to mysql, db2 to postgresql, db2 to sql server | another target engine | MySQL / PostgreSQL / SQL Server |
| sqlite to db2 | the reverse direction | SQLite to DB2 |
| db2 export to ixf / del, then load into sqlite | the export-file route | DB2 to CSV, then CSV to SQLite |
| a .sql dump of DB2 into sqlite | a script rather than a live source | SQL to SQLite |
| copy between two sqlite files | SQLite as both sides | Copy between SQLite files |
Verify Three Things After the First Copy
- Row counts on both sides:
SELECT COUNT(*)in DB2 against the table in the file - a difference means rejected rows, and the log names the table. - One decimal and one timestamp: read them back as they were stored -
typeof()in SQLite tells you whether the money went in as text or as a number. - The key you would sync on: run the copy twice with refresh mode - the second run must change nothing, which is what makes a scheduled sync safe.
Frequently Asked Questions
Download Withdata DBCopier Now
Start copying DB2 tables into SQLite files in seconds - free trial for Windows, Linux and macOS.
$75 one-time · volume discounts to $55 · 30-day money-back · pricing & licence terms

