From: | Christoph Berg <christoph(dot)berg(at)credativ(dot)de> |
---|---|
To: | Gennaro Sivero <gensiv08(at)gmail(dot)com> |
Cc: | pgeu-general(at)postgresql(dot)org |
Subject: | Re: How to import XML large file in Postgresql |
Date: | 2016-06-24 08:37:57 |
Message-ID: | 20160624083757.GA5459@msg.df7cb.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgeu-general |
Re: Gunnar "Nick" Bluth 2016-06-24 <3e6c5478-70ff-d7d8-c330-c142c7326711(at)pro-open(dot)de>
> # \set largexmlfile `cat INSERTFILENAMEHERE`
> # INSERT INTO mytable (xmldata) VALUES (:largexmlfile);
This worked for me when I 'quoted' the variable expansion:
INSERT INTO mytable (xmldata) VALUES (:'largexmlfile');
> Obviously, this will probably not work with _really_ large files... in
> that case, COPY or \copy with no delimiter might work.
I'm not sure it is possible to tell COPY to ignore line endings
(unless the xml file is just one giant line).
Generally, "pgloader" is a pretty decent import tool, I'd try that if
the simple approaches don't work.
Or even simpler, manually construct an insert statement in a new sql
file:
INSERT INTO mytable (xmldata) VALUES ($quote$
.... your xml data here
$quote$);
Christoph
From | Date | Subject | |
---|---|---|---|
Next Message | Tobias Bussmann | 2016-06-24 10:10:16 | Re: How to import XML large file in Postgresql |
Previous Message | Gunnar "Nick" Bluth | 2016-06-23 23:37:09 | Re: How to import XML large file in Postgresql |