1. 程式人生 > 其它 >PostgreSQL檢視索引、表對應的relfileno

PostgreSQL檢視索引、表對應的relfileno

pg_class就相當於oracle中dba_segments+dba_objects的並集。

檢視某個檔案或索引的relfileno

mydb2=# select relfilenode from pg_catalog.pg_class where relname='idx_my_tb2';
relfilenode
-------------
49307

[zjh@hs-10-20-30-193 data]$ find . -name "49307"
./base/49300/49307

檢視某個relfileno對應的物件

例如,查詢4930x這批的物件

mydb2=# select * from pg_catalog.pg_class where
relfilenode=49302; oid | relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | relt ablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasindex | relisshared | relpersistence | relkind | relnatts | relchecks | relhasrules | relhastriggers | relhassubc lass
| relrowsecurity | relforcerowsecurity | relispopulated | relreplident | relispartition | relrewrite | relfrozenxid | relminmxid | relacl | reloptions | relpartbound -------+---------+--------------+---------+-----------+----------+-------+-------------+----- ----------+----------+-----------+---------------+---------------+-------------+-------------
+----------------+---------+----------+-----------+-------------+----------------+----------- -----+----------------+---------------------+----------------+--------------+---------------- +------------+--------------+------------+--------+------------+-------------- 49302 | my_tb2 | 2200 | 49304 | 0 | 10 | 2 | 49302 | 0 | 0 | 0 | 0 | 0 | t | f | p | r | 2 | 0 | f | f | f | f | f | t | d | f | 0 | 587 | 1 | | | (1 row)

可知是物件my_tb2,型別定義在pg_type中,可以參見https://www.cnblogs.com/orangeform/archive/2012/05/25/2305415.html

花若盛開,蝶自飛來,你若精彩,幸福開懷!2020年12月11日-18日