4、postgresql拓展表空间
base是数据保存目录,
OID:对象标识符,无符号4字节整数,
数据库的oid在pg_database中,表,索引,序列等OID存储在pg_class中
表空间:pg最大的逻辑存储单元,表索引数据库都分配到对应表空间,创建数据库时会默认创建表空间,pg_default和pg_global两个表空间。
还可以自定义表空间,分配在不同性能的磁盘上
-bash-4.2$ mkdir new_space
-bash-4.2$ psql
psql (10.21)
Type "help" for help.
postgres=# \db+
List of tablespaces
Name | Owner | Location | Access privileges | Options | Size | Description
------------+----------+----------+-------------------+---------+---------+-------------
pg_default | postgres | | | | 1447 MB |
pg_global | postgres | | | | 574 kB |
(2 rows)
postgres=# create tablespace new_space location '/var/lib/pgsql/new_space';
CREATE TABLESPACE
postgres=# \db+
List of tablespaces
Name | Owner | Location | Access privileges | Options | Size | Description
------------+----------+--------------------------+-------------------+---------+---------+-------------
new_space | postgres | /var/lib/pgsql/new_space | | | 0 bytes |
pg_default | postgres | | | | 1447 MB |
pg_global | postgres | | | | 574 kB |
在新的表空间上创建表
postgres=# create tablespace new_space location '/var/lib/pgsql/new_space';
CREATE TABLESPACE
postgres=# \db+
List of tablespaces
Name | Owner | Location | Access privileges | Options | Size | Description
------------+----------+--------------------------+-------------------+---------+---------+-------------
new_space | postgres | /var/lib/pgsql/new_space | | | 0 bytes |
pg_default | postgres | | | | 1447 MB |
pg_global | postgres | | | | 574 kB |
(3 rows)
postgres=# create table new_test(id int ) tablespace new_space ;
CREATE TABLE
数据块在磁盘中叫page[读写的最小单位默认大小8kb],在内存中叫buffer
表和索引叫relation
行称为tuple
原文地址:https://blog.csdn.net/lycdf/article/details/140832740
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!