Posted by jayapal at 3:26 AM
Easy way to Import & Export as CSV file in postgreSQL using psql copy command.
COPY tablename From '/absolute _path_to_file/filename.csv' DELIMITERS '|' WITH NULL AS '';
COPY tablename To '/absolute _path_to_file/filename.csv' DELIMITERS '|' WITH NULL AS '';
- User should be superuser i.e postgres.
- Path should be absolute and have full permission (chmod 777).
- Should be in local-machine where postgreSQL installed.
- While importing data from csv to DB, the field and data order should be same. (Say, If we have table with fields as ID & Name, then data in csv file should be 1 & Jayapal )