如何知道Postgresql表空间是什么?

前端之家收集整理的这篇文章主要介绍了如何知道Postgresql表空间是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了一个名为indexes的新表空间,我试图删除旧的表空间indexes_old,它用来包含一些表和索引.当我尝试删除表空间时,我得到:
=> drop tablespace indexes_old;
ERROR:  tablespace "indexes_old" is not empty

但是,当我尝试看看那里有什么,似乎没有表生活在该表空间中:

=> select * from pg_tables where tablespace = 'indexes_old';
schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers
------------+-----------+------------+------------+------------+----------+-------------
(0 rows)

=> select * from pg_indexes where tablespace = 'indexes_old';
schemaname | tablename | indexname | tablespace | indexdef
------------+-----------+-----------+------------+----------
(0 rows)

那么那个表空间是什么阻止我放弃它呢?

如果重要,我刚刚使用pg_upgrade工具从Pg 8.4迁移到Pg 9.0.

表空间如下所示:

Name     |  Owner   |    Location     | Access privileges | Description 
-------------+----------+-----------------+-------------------+-------------
 indexes     | nobody   | /data/pgindex90 |                   | 
 indexes_old | nobody   | /data/pgindex84 |                   |

并且/ data / pgindex84的内容包括所有旧的8.4索引,加上pg_upgrade自动创建的新的9.0索引

# sudo ls -al /data/pgindex84/PG_9.0_201008051/11874
total 8280
drwx------ 2 postgres postgres    4096 Feb  9 14:58 .
drwx------ 3 postgres postgres    4096 Feb 11 09:28 ..
-rw------- 1 postgres postgres   40960 Feb  9 14:58 10462602
-rw------- 1 postgres postgres   40960 Feb  9 14:58 10462604
-rw------- 1 postgres postgres 4644864 Feb  9 14:58 10462614
-rw------- 1 postgres postgres 3727360 Feb  9 14:58 10462616
检查pg_class以查看位于哪里:
SELECT 
  c.relname,t.spcname 
FROM 
  pg_class c 
    JOIN pg_tablespace t ON c.reltablespace = t.oid 
WHERE 
  t.spcname = 'indexes_old';
原文链接:https://www.f2er.com/postgresql/192723.html

猜你在找的Postgre SQL相关文章