如何在 PostgreSQL 上查找表/索引所在的表空间?

Ama*_*rus 3 postgresql tablespaces postgresql-9.3

如何使用 PostgreSQL (9.3) 找出表(或索引)所在的表空间?

小智 7

例如,您有一张表example_table(可选择在多个架构中):

SELECT tablespace 
FROM pg_tables 
WHERE tablename = 'example_table' [AND schemaname = 'your_schema'];
Run Code Online (Sandbox Code Playgroud)

索引同样的事情example_index

SELECT tablespace 
FROM pg_indexes 
WHERE indexname = 'example_index' [AND schemaname = 'your_schema'];
Run Code Online (Sandbox Code Playgroud)