Search code examples
xmldatabaseexportpostgresql-9.3

Exporting postgres database data to XML


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?


Solution

  • 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