1

I'd like to export whole PostgreSQL database to, preferably but not necessarily, a single XML file. I've found a lot of guides and solutions that help achieve the SQL>XML export, but for a single table. Is it possible, and if yes then how, to export whole database using PgAdmin or console command to XML format?

Jack_Russell
  • 323
  • 5
  • 20

2 Answers2

2

In PostgreSQL you can do it like this:

SELECT database_to_xml(true, true, 'n');

see: https://www.postgresql.org/docs/current/static/functions-xml.html

Gholamali Irani
  • 4,391
  • 6
  • 28
  • 59
0

Thanks for help @Gholamali-Irani. It seems to do something for 2 minutes when I'm executing this query in PgAdmin, but where is the file stored? Can I specify the file name and path where it should be created? I've also found something about xPath function but I don't really understand the way it should be used or maybe I'm searching the solution in the wrong way?

Jack_Russell
  • 323
  • 5
  • 20
  • Have a look here: https://stackoverflow.com/questions/50276474/dump-postgresql-table-to-xml-file looks like you need to add 'to' and the path location – jumptiger13 Dec 15 '22 at 16:39