ERROR: relation "pg_buffercache" does not exist

创建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;

  

点赞