I have a file test.csv with two lines:
"smth", "1", "2", "3"
"smth more", "4", "5", "6"
I'm trying to copy it to a table with sql shell:
CREATE TABLE test_table(col1 TEXT, col2 TEXT, col3 TEXT, col4 TEXT);
COPY test_table FROM 'E:\\PostgreSQL13\\scripts\\test.csv';
And get the following error:
wrong syntax for type integer: """"smth"", ""1"", ""2"", ""3""""
What could be the problem here?
Thank you!
Tell copy you are inputing a csv
, so it will use the default comma separator and recognize the double quotes. ( text
format is the default)
COPY test_table FROM 'E:\\PostgreSQL13\\scripts\\test.csv' (FORMAT 'csv')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.