加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-13 16:29:00 所属栏目:百科 来源:网络整理
导读:我创建了一个名为indexes的新表空间,我试图删除旧的表空间indexes_old,它用来包含一些表和索引.当我尝试删除表空间时,我得到: = drop tablespace indexes_old;ERROR: tablespace "indexes_old" is not empty 但是,当我尝试看看那里有什么,似乎没有表生活在
我创建了一个名为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';

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读