Re: I have an exporting need...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Juan Hernández <dejesusog(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: I have an exporting need...
Date: 2024-05-14 14:54:29
Message-ID: 1091077.1715698469@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> On 13/05/2024 16:01, Juan Hernández 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?

> It'd be tricky to restore from, as you need to restore the tables in the
> right order. I think you'd still need a "main" sql file that includes
> all the other files in the right order. And using the table names as
> filenames gets tricky if the table names contain any funny characters.

It's a lot worse than that, as it's entirely possible to have circular
FK dependencies, meaning there is no "right order" if you think of
each table file as self-contained DDL plus data. Other sorts of
circularities are possible too.

pg_dump deals with that hazard by splitting things up: first create
all the tables, then load all the data, then create all the indexes
and foreign keys. You can tell it to just emit the parts relevant to
a particular table, but it's on your head whether that's actually
going to be useful in your context. I doubt that it's widely enough
useful to justify creating a special mode beyond what we already
have.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-05-14 14:55:59 Re: Dump-restore loosing 'attnotnull' bit for DEFERRABLE PRIMARY KEY column(s).
Previous Message Justin Pryzby 2024-05-14 14:49:53 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands