Copying CSV to Amazon RDS hosted Postgresql database

◇◆丶佛笑我妖孽 提交于 2019-12-05 02:37:46

You're using:

COPY tablename FROM 'filename';

this won't work - RDS has no idea what 'filename' is.

You must use the psql command's \copy, which copies from the local client, or PgAdmin-III's "import data" option.

The RDS manual covers this in more detail.

Workaround without using psql

1) Import data locally to a temporary table using simple copy command

2) Right click the table in the pgAdmin III object browser and select "Backup..."

3) Set the format to Plain and save the file as a .sql file

4) Click on the Dump Options #1 Tab and check Data

5) Click on the Dump Options #2 Tab and check Use Column Inserts and Use Insert Commands

6) Click Backup button

7) Now you can open the sql file and run it in your RDS server

Alternatively you can use the below command to generate the sql file

pg_dump --host localhost --port 5432 --username "postgres" --no-password  --format plain --section data --inserts --column-inserts --file "C:\test\test.sql" --table "public.envelopes" "testdb"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!