You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pgloader仅创建表列未复制数据:SQL Server转PostgreSQL迁移求助

问题排查与解决步骤
  • 连接协议错误:你的配置里FROM使用的是mysql://协议,但实际要迁移的是Microsoft SQL Server数据库,pgloader连接SQL Server必须用mssql://协议,这是数据无法加载的核心原因。修正后的连接串应为:

    FROM mssql://user:pass@db1/db1
    
  • 表匹配规则语法错误:including only table names matching ~/db1/, 'table'写法不符合pgloader规范。如果要匹配以db1开头的表,正确正则格式是~/^db1\./;如果是指定单个表,用including only tables ('db1.table')即可。

  • WITH子句参数冲突:create tables和data only同时使用存在逻辑矛盾——data only表示仅加载数据不建表,而create tables是创建表。若要先建表再导数据,去掉data only即可。

  • 并发参数优化:当前workers = 8但concurrency = 1,会限制数据加载的并行效率,可将concurrency调整为与workers匹配的值(比如concurrency = 4)。

修正后的完整配置示例:

LOAD DATABASE
FROM mssql://user:pass@db1/db1
INTO postgresql://user:pass@db2/db2
  including only table names matching ~/^db1\./
WITH create tables,
  workers = 8, concurrency = 4,
  multiple readers per thread, rows per range = 10000

执行时建议添加日志输出,方便排查问题:

pgloader --logfile migration.log your_config.load

内容的提问来源于stack exchange,提问作者luke Petrovici

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 04:11:04