Spanish Total.js
English
Documentation For AI agents
Contents

Make a copy of a database

TotalSQL writes a whole database to a SQL file that makes it again, for the five kinds of database and with nothing else to install.

.md GitHub
On this page

Make the copy

  1. Open the connection, and press Export the database…, the arrow next to its name.
  2. Leave With the rows of every table on, or turn it off to have only the structure.
  3. In Besides the tables and the views, choose what else goes in. All of it is marked at first.
  4. Press Choose where… A large database takes a while.

When it ends, the line at the bottom says how many tables, views and rows were saved.

In PostgreSQL, you can also make the copy with pg_dump, which has more in it.

What is in the file

The tables with their rows and their counters, their relations, and the views. And what you chose of the extensions, types, sequences, functions, procedures, triggers and events of your database.

The relations, the triggers and the events are made after the rows. So tables can point to each other, and restoring does not set anything off.

What is not

  • Roles and permissions, which belong to the server.
  • In PostgreSQL, the foreign tables, the range types, the comments of columns, and the division of a table into parts: all its rows go into one table.
  • In SQL Server, the table types, and the indexes of other kinds than the usual ones, such as columnstore and XML.
Try to restore a copy before you depend on it. For what is not in it, use the backup tool of your server or, in PostgreSQL, pg_dump.

The rows are read table by table, not at one instant. If others write in the database while you copy it, the tables may not agree with each other.

Restore it

For a file of up to 8 MB:

  1. Make an empty database, and open it in TotalSQL.
  2. In a query, press Open a SQL file… and choose the copy.
  3. Press Run, and confirm.

A larger file does not fit in the editor. Run it with the tool of your database: psql, mysql, sqlcmd or sqlite3. For example, in PostgreSQL:

psql --dbname=shop_copy --file=shop.sql

If restoring fails

It stops at the first error, and what ran before stays. Correct the cause, make the empty database again and start from the beginning of the file.

In MySQL, MariaDB and SQLite, the file turns off the check of the relations while the rows go in, and turns it on at its end. If it stops half way, close the connection and open it again before you go on.

Made in Europe