SQL, SQLite and DB files: inspect a database without changing the original
Distinguish SQL statements from a database file and inspect a local copy after identifying the format.
Follow the steps and understand the result
Step through at your own pace, or play the walkthrough to follow each stage.
What the file is
sample.sqlOpen or inspect it step by step
identify source → inspectConvert or export
sqlite3 -readonly sample-copy.sqliteVerify the result
repeat the task → compareWhat the file is
A SQL file usually contains text statements to create, query or change data. SQLite stores a database in a binary format and may use SQLITE or DB. DB is generic and does not prove the file is SQLite. Identify the creating app and look for a documented export.
Open or inspect it step by step
Inspect SQL as text before import; it can contain DROP, DELETE or engine-specific statements. For a known SQLite database, open a consistent test copy with a local reader in read-only mode, such as sqlite3 -readonly. For an active app use its export or documented backup method; copying just DB while it is in use can omit WAL changes.
Worked example
sqlite3 -readonly sample-copy.sqlite
SELECT name FROM sqlite_schema WHERE type = 'table';Convert or export
For one table, export CSV from a separate copy after checking fields. CSV does not carry indexes, relations or constraints. Migrating an entire database requires a schema, type review and an import plan for the target engine.
Verify the result
Compare row counts, field names and a sample with Arabic and empty values. Verify the original was not changed. If the file fails to open, check format, encryption or app export before attempting repairs.
What to watch for
Databases may contain account or business data. Use non-sensitive training samples and avoid importing unknown dumps into a real database.