Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restore from plain text 2

Status
Not open for further replies.

mhaupt

Programmer
Oct 30, 2007
1
CZ
Hello,
I want to load data into postgre db.
I have a data file in text format but pg_restore doesn't support plain format.
Is there any way to load plain data by pg_restore?
Or is there any way of loading data into db? (for example some utility used for migration from another db to postgre db)

Example of data (two records; two attributes):
1 aa
2 bb

Regards
mhaupt
 
try
Code:
\h COPY
in psql, or look here:
You may have to modify your data first, to generate quotes:
Code:
sed -i "s/  /, '/;s/$/'/;" datafile.csv
8, 'aa'
9, 'bb'
Code:
copy foo from '/path/to/datafile.csv' WITH delimiter ',';

If you're not used to sed, you could take openoffice.org:calc or some other spreadsheet software, to generate a csv-file.

don't visit my homepage:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top