pg-cmd - PostgreSQL interactive and batch query command-line tool »
parameters:
delimeter: delimiter char ("|",",","#","TAB","WHITESPACE")
quote: quote char (quote=' => single quotes, quote=" => double quotes)
header: y|n, data file contains field name at first line
schema: schema name, use this parameter to load specific schema's data, if not set, use logon user's default schema
table: table name
datafile: data file name
filetype: txt|tsv|csv
loadtype: append|replace|update|upsert
append: appends the new rows to the table.
replace: all rows in the table are deleted and the new data is loaded.
update: update the rows by the new data.
upsert upsert the rows by the new data.
updatekey: key feild to update/upsert with, usually use primary key.
nullif: specifies that the column should be loaded as NULL
("BLANKS" for zero length strings being loaded into numeric columns)
badfile: write the content that can not load to this badfile
errors: maxinum error count
quit = y|n (quit pg-cmd after run in batch mode)
example
In interactive mode:
pg-cmd> load table=media_messages
> datafile=f:\media_messages.txt
> filetype=txt
> delimiter=,
> quote="
> header=y;
In batch mode:
pg-cmd dsn="pan:withdata@192.168.0.102:5432/test" task=load table=media_messages datafile=f:\media_messages.txt filetype=txt delimiter=, quote=" header=y quit=y