代码改变世界

ERROR: relation "pg_buffercache" does not exist

2019-05-28 15:50  abce  阅读(2853)  评论(0编辑  收藏  举报

创建pg_buffercache后,查询时报错:

postgres=# create extension pg_buffercache;
postgres=# select * from pg_buffercache;
ERROR:  relation "pg_buffercache" does not exist
LINE 1: select * from pg_buffercache;

  

原因:消息'relation does not exist'通常是因为没有连接到相应数据库。因为我只是psql连接后,没有切换到某个数据库。

 

解决方法:

\c yourDb
yourDb=# CREATE EXTENSION IF NOT EXISTS pg_buffercache;
yourDb=# SELECT count(*) FROM pg_buffercache;