数据库内核之数据文件学习
Posted 丶Summer ~Z
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库内核之数据文件学习相关的知识,希望对你有一定的参考价值。
数据文件
实例目录下的数据文件
base
存放数据库数据文件
[postgres@local99:~/study/test/bin/data/base/13579]$ ls
112 13430_fsm 13445_fsm 2600_fsm 2606 2611 2618_fsm 2659 2678 2693 2831 2995 3351 3456 3575 3603 3997 4157 4172 827
113 13430_vm 13445_vm 2600_vm 2606_fsm 2612 2618_vm 2660 2679 2696 2832 2996 3379 3456_fsm 3576 3603_fsm 4143 4158 4173 828
1247 13432 13447 2601 2606_vm 2612_fsm 2619 2661 2680 2699 2833 3079 3380 3456_vm 3596 3603_vm 4144 4159 4174 pg_filenode.map
1247_fsm 13434 13449 2601_fsm 2607 2612_vm 2619_fsm 2662 2681 2701 2834 3079_fsm 3381 3466 3597 3604 4145 4160 5002 PG_VERSION
1247_vm 13435 1417 2601_vm 2607_fsm 2613 2619_vm 2663 2682 2702 2835 3079_vm 3394 3467 3598 3605 4146 4161 548
1249 13435_fsm 1418 2602 2607_vm 2615 2620 2664 2683 2703 2836 3080 3394_fsm 3468 3599 3606 4147 4162 549
1249_fsm 13435_vm 174 2602_fsm 2608 2615_fsm 2650 2665 2684 2704 2837 3081 3394_vm 3501 3600 3607 4148 4163 6102
1249_vm 13437 175 2602_vm 2608_fsm 2615_vm 2651 2666 2685 2753 2838 3085 3395 3502 3600_fsm 3608 4149 4164 6104
1255 13439 2187 2603 2608_vm 2616 2652 2667 2686 2753_fsm 2838_fsm 3118 3429 3503 3600_vm 3609 4150 4165 6106
1255_fsm 13440 2224 2603_fsm 2609 2616_fsm 2653 2668 2687 2753_vm 2838_vm 3119 3430 3534 3601 3712 4151 4166 6110
1255_vm 13440_fsm 2328 2603_vm 2609_fsm 2616_vm 2654 2669 2688 2754 2839 3164 3431 3541 3601_fsm 3764 4152 4167 6111
1259 13440_vm 2336 2604 2609_vm 2617 2655 2670 2689 2755 2840 3256 3433 3541_fsm 3601_vm 3764_fsm 4153 4168 6112
1259_fsm 13442 2337 2605 2610 2617_fsm 2656 2673 2690 2756 2840_fsm 3257 3439 3541_vm 3602 3764_vm 4154 4169 6113
1259_vm 13444 2579 2605_fsm 2610_fsm 2617_vm 2657 2674 2691 2757 2840_vm 3258 3440 3542 3602_fsm 3766 4155 4170 6117
13430 13445 2600 2605_vm 2610_vm 2618 2658 2675 2692 2830 2841 3350 3455 3574 3602_vm 3767 4156 4171 826
[postgres@local99:~/study/test/bin/data/base/13579]$
表数据文件有三个,以表的oid命令,可以根据表的oid查看对应的表名
postgres=# select * from pg_class where oid= 1247;
oid | relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasindex | relisshared | re
lpersistence | relkind | relnatts | relchecks | relhasrules | relhastriggers | relhassubclass | relrowsecurity | relforcerowsecurity | relispopulated | relreplident | relispartition | relre
write | relfrozenxid | relminmxid | relacl | reloptions | relpartbound
------+---------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-------------+---
-------------+---------+----------+-----------+-------------+----------------+----------------+----------------+---------------------+----------------+--------------+----------------+------
------+--------------+------------+-----------------------------------------+------------+--------------
1247 | pg_type | 11 | 71 | 0 | 10 | 2 | 0 | 0 | 10 | 411 | 10 | 4171 | t | f | p
| r | 31 | 0 | f | f | f | f | f | t | n | f |
0 | 479 | 1 | postgres=arwdDxt/postgres,=r/postgres | |
(1 row)
postgres=# select * from pg_class where oid= 1249;
oid | relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasindex | relisshared
| relpersistence | relkind | relnatts | relchecks | relhasrules | relhastriggers | relhassubclass | relrowsecurity | relforcerowsecurity | relispopulated | relreplident | relispartition |
relrewrite | relfrozenxid | relminmxid | relacl | reloptions | relpartbound
------+--------------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+------------
-+----------------+---------+----------+-----------+-------------+----------------+----------------+----------------+---------------------+----------------+--------------+----------------+-
-----------+--------------+------------+-----------------------------------------+------------+--------------
1249 | pg_attribute | 11 | 75 | 0 | 10 | 2 | 0 | 0 | 53 | 2861 | 53 | 0 | t | f
| p | r | 25 | 0 | f | f | f | f | f | t | n | f |
0 | 479 | 1 | postgres=arwdDxt/postgres,=r/postgres | |
(1 row)
postgres=# select * from pg_class where oid= 1255;
oid | relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasindex | relisshared | re
lpersistence | relkind | relnatts | relchecks | relhasrules | relhastriggers | relhassubclass | relrowsecurity | relforcerowsecurity | relispopulated | relreplident | relispartition | relre
write | relfrozenxid | relminmxid | relacl | reloptions | relpartbound
------+---------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-------------+---
-------------+---------+----------+-----------+-------------+----------------+----------------+----------------+---------------------+----------------+--------------+----------------+------
------+--------------+------------+-----------------------------------------+------------+--------------
1255 | pg_proc | 11 | 81 | 0 | 10 | 2 | 0 | 0 | 81 | 3034 | 81 | 2836 | t | f | p
| r | 29 | 0 | f | f | f | f | f | t | n | f |
0 | 479 | 1 | postgres=arwdDxt/postgres,=r/postgres | |
(1 row)
postgres=#
1247
: oid为1247的表对应的表数据,即实际存储表数据的文件
1247_fsm
: 存储空闲空间索引,用来索引1247表文件中的空闲空间,从而可以为需要插入的数据快速找到空闲的空间
1247_vm
:用于标识数据库中表的可见性的文件
global
该目录存储全局的数据文件,如pg_database、pg_control文件等一些共享数据
[postgres@local99:~/study/test/bin/data/global]$ ls
1213 1214 1232 1260_fsm 1261_fsm 1262_fsm 2396_fsm 2671 2677 2697 2847 2966 3593 4175 4178 4183 4186 6002 6115 pg_internal.init
1213_fsm 1214_fsm 1233 1260_vm 1261_vm 1262_vm 2396_vm 2672 2694 2698 2964 2967 4060 4176 4181 4184 6000 6100 pg_control
1213_vm 1214_vm 1260 1261 1262 2396 2397 2676 2695 2846 2965 3592 4061 4177 4182 4185 6001 6114 pg_filenode.map
[postgres@local99:~/study/test/bin/data/global]$
postgres=# select * from pg_class where oid= 1213;
oid | relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasindex | relisshare
d | relpersistence | relkind | relnatts | relchecks | relhasrules | relhastriggers | relhassubclass | relrowsecurity | relforcerowsecurity | relispopulated | relreplident | relispartition |
relrewrite | relfrozenxid | relminmxid | relacl | reloptions | relpartbound
------+---------------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-----------
--+----------------+---------+----------+-----------+-------------+----------以上是关于数据库内核之数据文件学习的主要内容,如果未能解决你的问题,请参考以下文章