postgresql-9.3 - 在 aws postgres rds 中将表到表数据从一个数据库复制到另一个数据库
问题描述
我有一个aws postgres rds,在这个下有两个数据库,所以我想将一个数据库表数据导入另一个数据库表意味着表到表的数据传输,但是在从一个导入表数据时遇到约束和fkey错误等错误表到另一个。我听说了一些 XML 数据文件解决方案,可以将其从一个表导出和导入到另一个表,但不确定这个选项。可以建议是否有人为 aws postgres rds 做过类似的事情。尝试使用以下选项在 AWS postgres RDS 下从一个数据库表转储和还原到另一个数据库表,但出现错误。
pg_dump -h <dns name> -U <user name> -p 5432 -t <table name> -d <db a> -f bkp.sql -v
psql -h <dns name> -U <user name> -p 5432 --table <table name> -d <db b>-f bkp.xml -verbose
面临以下错误
SET
SET
SET
SET
SET
set_config
------------
(1 row)
SET
SET
SET
SET
SET
SET
psql:bkpq.bkp:42: ERROR: relation "testtable" already exists
ALTER TABLE
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
COMMENT
psql:bkpq.bkp:154: ERROR: relation "testtable _id_seq" already exists
ALTER TABLE
ALTER SEQUENCE
ALTER TABLE
psql:bkpq.bkp:253: ERROR: duplicate key value violates unique constraint "testtable _pkey"
DETAIL: Key (id)=(84) already exists.
CONTEXT: COPY testtable, line 1
setval
--------
129
(1 row)
psql:bkpq.bkp:268: ERROR: multiple primary keys for table "testtable " are not allowed
psql:bkpq.bkp:276: ERROR: relation "testtable _unique_name" already exists
psql:bkpq.bkp:283: ERROR: relation "testtable_process_platform_process_id_index" already exists
psql:bkpq.bkp:290: ERROR: relation "testtable _process_platform_process_type_id_index" already exists
psql:bkpq.bkp:298: ERROR: constraint "testtable _process_create_uid_fkey" for relation "" already exists
psql:bkpq.bkp:306: ERROR: constraint "testtable _process_partner_process_model_id_fkey" for relation "testtable" already exists
psql:bkpq.bkp:314: ERROR: constraint "testtable _process_product_template_process_model_id_fkey" for relation "testtable" already exists
psql:bkpq.bkp:322: ERROR: constraint "testtable _process_quote_item_wizard_process_config_model_id_fkey" for relation "testtable" already exists
psql:bkpq.bkp:330: ERROR: constraint " testtable_process_type_id_fkey" for relation "testtable" already exists
psql:bkpq.bkp:338: ERROR: constraint "testtable _process_write_uid_fkey" for relation "testtable " already exists
GRANT
GRANT
GRANT
解决方案
如果这是序列的问题,您可以尝试通过手动设置下一个值来修复
推荐阅读
- python - 类型错误:预测()缺少 1 个必需的位置参数:'params'
- php - PHP中的会话未注册
- javascript - 如何知道电子邮件是否已经在firebase身份验证中注册,javascript?
- go - golang中的grpc服务器并发模型
- php - 自定义排序多维与 n 项最高值
- python - 如何对齐包含 MatPlotLib 中上下索引的刻度标签?
- pandas - 如何在熊猫数据框中的多列中使用多个算术函数
- spring - JwtAuthenticationToken 无法解析为类型
- python - 在python中长按键盘按下监听器
- apache-spark - apache spark过滤器方法中的HTTP API调用