And*_*ter 20 postgresql tablespace
我创建了一个名为的新表空间indexes,我正在尝试删除旧的表空间indexes_old,它曾经包含一些表和索引.当我尝试删除表空间时,我得到:
=> drop tablespace indexes_old;
ERROR: tablespace "indexes_old" is not empty
Run Code Online (Sandbox Code Playgroud)
但是当我试图看到那里有什么时,似乎没有表存在于该表空间中:
=> 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)
Run Code Online (Sandbox Code Playgroud)
那么那个表空间阻止我放弃它的是什么?
如果重要,我只是使用pg_upgrade工具从Pg 8.4迁移到Pg 9.0.
表空间如下所示:
Name | Owner | Location | Access privileges | Description
-------------+----------+-----------------+-------------------+-------------
indexes | nobody | /data/pgindex90 | |
indexes_old | nobody | /data/pgindex84 | |
Run Code Online (Sandbox Code Playgroud)
并且/ 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
Run Code Online (Sandbox Code Playgroud)
Fra*_*ens 14
检查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';
Run Code Online (Sandbox Code Playgroud)
在PostgreSQL中,任何PostgreSQL数据库都可以使用表空间.(只要请求用户具有足够的权限,即.)我认为这个查询
SELECT spcname, spclocation FROM pg_tablespace;
Run Code Online (Sandbox Code Playgroud)
将显示index_old在PostgreSQL版本到9.1中的文件系统中使用的目录.在那里徘徊,看看是否有真实的东西在你的方式.尽管如此,除了使用PostgreSQL的界面之外,我会非常谨慎地尝试删除任何内容.
在9.2+,尝试
select spcname, pg_tablespace_location(oid) from pg_tablespace;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27942 次 |
| 最近记录: |