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';
COPY user FROM '/home/user/user_data' WITH DELIMITER '|';
Note: In absence of the option with delimiter
, the default delimiter is comma ,
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.