Aug 1, 2017

importing .csv to postgresql

First create the table with column names and sizes in accordance with .csv

Run The SQL:
COPY my_table FROM 'C:\Users\Administrator\Desktop\wrd78.csv' DELIMITER ',' CSV;
OUTPUT Meaage:
ERROR:  invalid input syntax for integer: "userName"
CONTEXT:  COPY my_table, line 1, column userName: "userName"
********** Error **********
ERROR: invalid input syntax for integer: "userName"
SQL state: 22P02
Context: COPY my_table, line 1, column userName: "userName"
Reason: .csv file has data at ‘userName’row which is character should have been integer.
Solution: Delete the particular row (Mostly it is the column names not data)

Run The SQL Again:
OUTPUT Meaage:
Solution: right click on 'my_table' > sequrity >edit >add> Enter the obj name to select as Everyone
And give all the permission to 'Everyone'

Run The SQL:
Query returned successfully: 14523 rows affected, 161 msec execution time.