create table emp (emp_id integer,
emp_name varchar(30),
registered_course varchar(15),
progress integer);
I'm having data in csv as :
emp_id, emp_name, registered_course
1,"vignesh","java",10
2,"rakesh","",
i.e., In my csv NULL integer column data is represented as unquoted empty string and NULL varchar data is represented as ""
Now, when I'm trying to upload csv to Postgres using copy from command in place of int columns of postgres I can see NULL is inserted but where as for varchar I can see it's blank/zero length string).
so far my command:
String copyQuery="COPY "+tableName+"("+columns+") FROM STDIN WITH DELIMITER ',' CSV HEADER";
long rowsInserted;
try {
rowsInserted = new CopyManager((BaseConnection) conPost)
.copyIn(
copyQuery,new FileReader(filePath)
);
}
In documentation :- https://www.postgresql.org/docs/current/sql-copy.html I can see that NULL Specifies the string that represents a null value and by default it is an unquoted empty string in CSV format. So this is why I can see for null integer data which is in csv as unquoted empty string represented as NULL after loading.
But, now how can I make NULL varchar data which in csv as "" to represented as NULL at postgres ??? as of now it is representing as empty string (blank/zero length).
Thanks in advance