Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Schema tools: dump, insert and diff

The three command-line schema tools of Exponential - ezsqldumpschema.php to dump a schema and data to .dba or SQL, ezsqlinsertschema.php to load them into any SQL engine, and ezsqldiff.php to compare two schemas with an…

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/help/database-administrators/schema-tools-dump-insert-diff.md

On this page

Schema tools: dump, insert and diff

This page is for database administrators who dump, load or compare Exponential schemas. Three scripts in bin/php/ do it, each also available through the console (exp:ezsqldumpschema, exp:ezsqlinsertschema, exp:ezsqldiff). The options below are copied from their --help output in 6.0.15; run --help on your release before you rely on one.

Contents

  1. Before you start
  2. ezsqldumpschema.php
  3. ezsqlinsertschema.php
  4. ezsqldiff.php
  5. Examples
  6. Checklist

Before you start

  • The --password= option puts the password on the command line, visible in the process list. Run the tools on a machine you control or with a temporary password.
  • --type takes a schema handler type from settings/dbschema.ini; for SQLite the database argument is the file name, as in Database. The scripts' own help lists only some types; sqlite3 and, with ezoracle, oracle work as well (9.9).
  • Add --allow-root-user when you run them as root.

ezsqldumpschema.php

ezsqldumpschema.php [OPTION]... [DATABASE] [FILENAME] dumps the schema, the data or both to a file or standard output.

OptionMeaning
--type, --host, --port, --socket, --user, --passwordthe source database (--socket MySQL only)
--output-arraya file with array structures (human readable): the .dba format
--output-serializedserialized data (saves space)
--output-sqlSQL for the source engine
--format=generic or localgeneric suits all databases (default); local only the one it was dumped from
--output-types=schema, data, allwhat to dump (default: schema only)
--diff-friendlySQL output friendlier to diff
--meta-dataextra engine-specific information
--table-type, --table-charsetfor SQL output (MySQL table types: bdb, innodb, myisam)
--compatible-sql, --no-sort, --allow-multi-insertoutput details
--schema-fileonly when dumping from files

ezsqlinsertschema.php

ezsqlinsertschema.php [OPTION]... [FILENAME] [DATABASE] loads a .dba schema and data into a database.

OptionMeaning
--type, --host, --port, --socket, --user, --passwordthe target database
--insert-types=schema, data, all, nonewhat to load (default: schema only); none with --clean-existing only cleans
--schema-filethe schema file, required when importing a schema
--table-type, --table-charsettable options for the target
--allow-multi-insertmulti-row inserts where the engine supports them
--clean-existingremoves all database objects before loading

--clean-existing empties the target database. Check the DATABASE argument twice, and never point it at a production database by accident. On PostgreSQL the installer corrects the sequences after loading data.

ezsqldiff.php

ezsqldiff.php [OPTION]... [SOURCE] [MATCH] shows the differences between two schemas and sets the exit code: 0 when they match, 1 when they differ.

OptionMeaning
--type, --host, --user, --password, --socketone connection for both sides
--source-*, --match-*separate connections per side
--check-onlyno SQL, only the exit code
--reversereverse the differences
--lint-checkcheck the source schema against the naming rules instead of comparing (The .dba schema format)

Types: mysql and postgresql. A side can be a .dba file. To compare your database with the release, give the reference schema first; the output is the SQL that would turn your database into the reference. Read it, do not run it: a DROP TABLE line often names a table of your own extension (11.7).

Examples

Dump schema and data of a MySQL site into one portable file:

php bin/php/ezsqldumpschema.php --type=mysql --host=localhost --user=exponential --password='<password>' \
    --format=generic --output-array --output-types=all exponential var/backup/site.dba --allow-root-user

Load it into PostgreSQL:

php bin/php/ezsqlinsertschema.php --type=postgresql --host=localhost --user=exponential --password='<password>' \
    --insert-types=all --schema-file=var/backup/site.dba var/backup/site.dba exponential --allow-root-user

Compare a MySQL database with the release's schema:

php bin/php/ezsqldiff.php --type=mysql --user=exponential --password='<password>' share/db_schema.dba exponential --allow-root-user
echo $?        # 0: the same, 1: differences

Keep dumps out of the web root: var/backup/ is below var/, which the shipped rewrite rules do not serve, but check your server as for the SQLite file (Securing the database).

Checklist

  • To do: --help read on your release.
  • To do: Passwords on the command line only on a machine you control.
  • To do: --clean-existing used only against a target you meant to empty.
  • To do: Diff output read and reviewed, never piped into the database.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x