【发布时间】:2022-08-02 19:41:04
【问题描述】:
我使用此命令将 postgresql 数据库从 v9.6 升级到 v12:
/opt/rh/rh-postgresql12/root/usr/bin/pg_upgrade -b /opt/rh/rh-postgresql96/root/usr/bin/ -B /opt/rh/rh-postgresql12/root/usr/bin/ -d /var/opt/rh/rh-postgresql96/lib/pgsql/data -D /var/opt/rh/rh-postgresql12/lib/pgsql/data
我没有出错,升级成功,但是当我试图从我的数据库中获取一些数据时,我意识到所有的数据库表都是空的。 数据库的大小在某种程度上与旧数据库相同,运行以下命令会返回所有表,但只有 0 行:
select n.nspname as table_schema,c.relname as table_name, c.reltuples as rows
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where c.relkind = \'r\'
and n.nspname not in (\'information_schema\',\'pg_catalog\')
order by c.reltuples desc;
你能告诉我为什么表格没有行吗?
-
升级后您是否运行
analyze(最后由 pg_upgrade 推荐)? -
@a_horse_with_no_name 不,我没有,您认为这可以解决问题吗?
-
@a_horse_with_no_name 运行该脚本确实解决了这个问题,谢谢。如果您添加您所说的作为答案,我可以批准它:)
标签: postgresql postgresql-9.6 postgresql-12 pg-upgrade