On Tue, 14 May 2024 at 06:18, Juan Hernández <dejesu...@gmail.com> wrote: > Do you consider useful to add a parameter (for example, --separatetables) so > when used the exporting file process can create a different tablename.sql > file for each table in database automatically? > > Example... > > PGHOST="/tmp" PGPASSWORD="mydbpass" pg_dump -U dbusername --separatetables > -Fp --inserts dbname > "/route/dbname.sql" > > And if this database has tables table1...table10, then 10 files are created...
pg_dump has code to figure out the dependency of objects in the database so that the dump file produced can be restored. If one file was output per table, how would you know in which order to restore them? For example, you have a table with a FOREIGN KEY to reference some other table, you need to restore the referenced table first. That's true for both restoring the schema and restoring the data. David