- DBeaver Database
- SQLite ERD with DBeaver
- DBeaver Full SQL Dump
Can you use DBeaver to create a SQL file that rebuilds your database from scratch? Yes, for databases such as MySQL and PostgreSQL, and you can do it in DBeaver Community Edition. If you’re working with SQLite, the steps are different.
A full SQL dump is a text file with the SQL needed to recreate a database’s structure and load its data. I find it handy when I want to rebuild a project database in a clean environment or see what the database looks like after months of changes.
How to create a SQL dump in DBeaver
For supported databases, DBeaver runs the database engine’s own backup utility. For example, it uses mysqldump for MySQL and pg_dump for PostgreSQL.
- In DBeaver’s database navigator, right-click the database you want to export.
- For MySQL, choose Tools > Dump database. For PostgreSQL, choose Tools > Backup.
- Select the objects you want to include. For a full dump, include all the relevant schemas or tables and keep both structure and data in the export.
- For PostgreSQL, choose Plain if you want a readable SQL script. If DBeaver asks for a Local Client, point it to the installed database client tools.
- Choose the output folder and file name, then click Start.
DBeaver’s backup and restore documentation covers the options for each database engine.
How to create a full SQL dump of a SQLite database
SQLite is outside DBeaver’s documented native backup workflow. If you already use DBeaver to work with a SQLite file, you can open that same file with the SQLite command-line tool and use its .dump command.
Start the SQLite shell from a terminal. Replace my_database.sqlite with the name or path of your existing database.
sqlite3 my_database.sqlite
At the SQLite prompt, run these commands to write the dump to my_database.sql.
.once my_database.sql
.dump
.quit
To test the dump, start SQLite with a new file name, such as my_database_test.sqlite. At the SQLite prompt, read the script and check the rebuilt database.
.read my_database.sql
PRAGMA integrity_check;
PRAGMA foreign_key_check;
Look for ok from the integrity check and no rows from the foreign-key check. Then open the rebuilt file in DBeaver and compare the tables, views, and a few key row counts with the original.
If you prefer a graphical tool for the export, here’s my walkthrough on creating a full SQL dump with DB Browser for SQLite. The command-line method is covered in the SQLite shell documentation.
What if you only need a few tables?
In DBeaver, select the tables you want and use Generate SQL > DDL to get their definitions. To export the rows, select the tables, choose Export Data, and pick SQL as the format. That gives you INSERT statements. If you assemble your own rebuild script from these exports, check which views, indexes, and triggers you need to include. With immediate foreign-key checks enabled, load the referenced rows before the rows that depend on them.