Is it possible to export an entire DB in a form where it can be
re-imported? For each table in a DB, output to a line-sequential file?
I have found that:
echo "select 'insert into $table values', * from $table |
psql -F " " -A -t $database >> outfile.txt
Does at least give a file of sql statements. But the strings are not
quoted or escaped. So multi-word fields, and field''''s with quotes
mess up.
For this I also need a list of tables in a DB. I can use:
for $table in read `echo "\dt" | psql -F " " -A -t rr | awk '{ print $2 }'`
do
(as above)
done
But it's getting a little weigted! I can't help fealing there must be
some clever option I am missing for dumping a DB in a form designed for
re-import, without all this work!
Thanks in advance if anybody can give me a hand...
Ben