Using Copy to import
suggest changeTo Copy Data from a CSV file to a table
COPY <tablename> FROM '<filename with path>';
To insert into table user
from a file named user_data.csv
placed inside /home/user/
:
COPY user FROM '/home/user/user_data.csv';
To Copy data from pipe separated file to table
COPY user FROM '/home/user/user_data' WITH DELIMITER '|';
Note: In absence of the option with delimiter
, the default delimiter is comma ,
To ignore header line while importing file
Use the Header option:
COPY user FROM '/home/user/user_data' WITH DELIMITER '|' HEADER;
Note: If data is quoted, by default data quoting characters are double quote. If the data is quoted using any other character use the QUOTE
option; however, this option is allowed only when using CSV format.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents