Re: [GENERAL] COPY command & binary format
Le 10/05/2016 à 12:56, Nicolas Paris a écrit : Hello, What is the way to build a binary format (instead of a csv) ? Is there specification for this file ? http://www.postgresql.org/docs/9.5/static/sql-copy.html Could I create such format from java ? I guess this would be far faster, and maybe safer than CSVs Thanks by advance, Hi Making a driver that do what you want is not difficult. You will achieve better performances than than loading data from CSV, and you also will have better precision for floating values (there is no text conversion). In the link you provide there is a description of the file format in section Binary Format. Mathieu Pujol
Re: [GENERAL] COPY command & binary format
On Tue, May 10, 2016 at 4:36 PM Sameer Kumarwrote: > On Tue, May 10, 2016 at 4:26 PM Nicolas Paris wrote: > >> Hello, >> >> What is the way to build a binary format (instead of a csv) ? Is there >> specification for this file ? >> http://www.postgresql.org/docs/9.5/static/sql-copy.html >> > >> >> Could I create such format from java ? >> > > You can use COPY JDBC API to copy to STDOUT and then compress it before > you use usual Java file operations to write it to a file. You will have to > follow the reverse process while reading from this file and LOADING to a > table. > > But why would you want to do that? > > >> >> I guess this would be far faster, and maybe safer than CSVs >> > > I don't think assumption is right. COPY is not meant for backup, it is for > LOAD and UN-LOAD. > > What you probably need is pg_dump with -Fc format. > http://www.postgresql.org/docs/current/static/app-pgdump.html > > Like someone else suggested upthread you can use Binary format in COPY command (default is text) > >> Thanks by advance, >> > -- > -- > Best Regards > Sameer Kumar | DB Solution Architect > *ASHNIK PTE. LTD.* > > 101 Cecil Street, #11-11 Tong Eng Building, Singapore 069 533 > > T: +65 6438 3504 | M: +65 8110 0350 | www.ashnik.com > -- -- Best Regards Sameer Kumar | DB Solution Architect *ASHNIK PTE. LTD.* 101 Cecil Street, #11-11 Tong Eng Building, Singapore 069 533 T: +65 6438 3504 | M: +65 8110 0350 | www.ashnik.com
Re: [GENERAL] COPY command & binary format
On Tue, May 10, 2016 at 4:26 PM Nicolas Pariswrote: > Hello, > > What is the way to build a binary format (instead of a csv) ? Is there > specification for this file ? > http://www.postgresql.org/docs/9.5/static/sql-copy.html > > > Could I create such format from java ? > You can use COPY JDBC API to copy to STDOUT and then compress it before you use usual Java file operations to write it to a file. You will have to follow the reverse process while reading from this file and LOADING to a table. But why would you want to do that? > > I guess this would be far faster, and maybe safer than CSVs > I don't think assumption is right. COPY is not meant for backup, it is for LOAD and UN-LOAD. What you probably need is pg_dump with -Fc format. http://www.postgresql.org/docs/current/static/app-pgdump.html > > Thanks by advance, > -- -- Best Regards Sameer Kumar | DB Solution Architect *ASHNIK PTE. LTD.* 101 Cecil Street, #11-11 Tong Eng Building, Singapore 069 533 T: +65 6438 3504 | M: +65 8110 0350 | www.ashnik.com