对PostgreSQL中tablespace 与 database, table的理解
开始:
当前的tablesapce信息
pgsql=# select * from pg_tablespace;
spcname | spcowner | spclocation | spcacl | spcoptions
------------+----------+-----------------------+--------+------------
pg_default | 10 | | |
pg_global | 10 | | |
tbs01 | 10 | /home/pgsql/tbs/tbs01 | |
(3 rows) pgsql=#
查看目录结构:
[pgsql@localhost tbs]$ tree
.
|-- dbtbs01
|-- dbtbs02
|-- tbs01
| `-- PG_9.1_201105231
`-- tbs02 5 directories, 0 files
[pgsql@localhost tbs]$
增设tablespace:
pgsql=# create tablespace dbtbs01 location '/home/pgsql/tbs/dbtbs01';
CREATE TABLESPACE
pgsql=#
创建数据,使用此tablespace:
使用上述tablespace建立数据库,在该数据库下建表:
[pgsql@localhost bin]$ ./psql
psql (9.1.2)
Type "help" for help. pgsql=# create database db1 owner pgsql tablespace dbtbs01;
CREATE DATABASE
pgsql=# \connect db1;
You are now connected to database "db1" as user "pgsql".
db1=# create table tab100(id integer);
CREATE TABLE
db1=# insert into tab100 values(generate_series(1,1000000));
INSERT 0 1000000
db1=# select pg_relation_filepath('tab100');
pg_relation_filepath
-------------------------------------------------
pg_tblspc/139315/PG_9.1_201105231/139316/139317
(1 row) db1=#
[pgsql@localhost tbs]$ pwd
/home/pgsql/tbs
[pgsql@localhost tbs]$ tree
.
|-- dbtbs01
| `-- PG_9.1_201105231
| `--
| |--
| |-- 12436_fsm
| |-- 12436_vm
| |--
| |-- 12438_fsm
| |-- 12438_vm
| |--
| |--
| |--
| |-- 12442_fsm
| |-- 12442_vm
| |--
| |--
| |--
| |-- 12446_fsm
| |-- 12446_vm
| |--
| |--
| |--
| |--
| |--
| |--
| |-- 12458_fsm
| |-- 12458_vm
| |--
| |--
| |--
| |--
| |--
| |-- 12465_fsm
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |-- 12476_fsm
| |-- 12476_vm
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |-- 12489_fsm
| |-- 12489_vm
| |--
| |--
| |--
| |-- 12493_fsm
| |-- 12493_vm
| |--
| |--
| |--
| |-- 12497_fsm
| |-- 12497_vm
| |--
| |--
| |--
| |-- 12501_fsm
| |-- 12501_vm
| |--
| |--
| |--
| |-- 12505_fsm
| |-- 12505_vm
| |--
| |--
| |--
| |-- 12509_fsm
| |-- 12509_vm
| |--
| |--
| |--
| |--
| |-- 12514_fsm
| |-- 12514_vm
| |--
| |--
| |--
| |-- 12518_fsm
| |-- 12518_vm
| |--
| |--
| |--
| |--
| |--
| |-- 12525_fsm
| |-- 12525_vm
| |--
| |--
| |-- 12528_fsm
| |-- 12528_vm
| |--
| |-- 12530_fsm
| |-- 12530_vm
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |-- 12543_fsm
| |-- 12543_vm
| |--
| |--
| |--
| |--
| |-- 12549_fsm
| |-- 12549_vm
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |-- 12558_fsm
| |-- 12558_vm
| |--
| |--
| |--
| |-- 12562_fsm
| |-- 12562_vm
| |--
| |--
| |--
| |--
| |-- 12567_fsm
| |-- 12567_vm
| |--
| |--
| |--
| |--
| |--
| |-- 12608_fsm
| |-- 12608_vm
| |--
| |--
| |--
| |-- 12612_fsm
| |-- 12612_vm
| |--
| |--
| |-- 12615_fsm
| |-- 12615_vm
| |--
| |--
| |--
| |-- 12619_fsm
| |-- 12619_vm
| |--
| |--
| |--
| |-- 12623_fsm
| |-- 12623_vm
| |--
| |--
| |--
| |-- 12627_fsm
| |-- 12627_vm
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |--
| |-- 12652_fsm
| |-- 12652_vm
| |--
| |--
| |--
| |-- 12656_fsm
| |-- 12656_vm
| |--
| |--
| |--
| |-- 12661_fsm
| |-- 12661_vm
| |--
| |--
| |--
| |-- 12666_fsm
| |-- 12666_vm
| |--
| |--
| |--
| |-- 12671_fsm
| |-- 12671_vm
| |--
| |--
| |--
| |-- 12676_fsm
| |-- 12676_vm
| |--
| |--
| |--
| |-- 12681_fsm
| |-- 12681_vm
| |--
| |--
| |--
| |--
| |--
| |--
| |-- 139317_fsm
| |-- PG_VERSION
| |-- pg_filenode.map
| `-- pg_internal.init
|-- dbtbs02
|-- tbs01
| `-- PG_9.1_201105231
`-- tbs02 7 directories, 231 files
[pgsql@localhost tbs]$
先看数据库信息:
db1=# select oid,datname from pg_database;
oid | datname
--------+-----------
1 | template1
12691 | template0
12699 | postgres
16384 | pgsql
16386 | tester
139316 | db1
(6 rows) db1=#
再仔细看看刚刚建立的表,位于何处:
db1=# select pg_relation_filepath('tab100');
pg_relation_filepath
-------------------------------------------------
pg_tblspc/139315/PG_9.1_201105231/139316/139317
(1 row)
db1=#
我的数据库cluster根目录是 /home/pgsql/DemoDir
可以看到:
[pgsql@localhost DemoDir]$ pwd
/home/pgsql/DemoDir
[pgsql@localhost DemoDir]$ find ./ -name ""
./pg_tblspc/
[pgsql@localhost DemoDir]$
我的表的真实路径位于:
[pgsql@localhost tbs]$ pwd
/home/pgsql/tbs
[pgsql@localhost tbs]$ find ./ -name ""
./dbtbs01/PG_9.1_201105231//
[pgsql@localhost tbs]$
可以看到,pg_tblspc/139315/PG_9.1_201105231/139316/139317 是拼接出来的。
看实际大小:
[pgsql@localhost ]$ pwd
/home/pgsql/tbs/dbtbs01/PG_9.1_201105231/
[pgsql@localhost ]$ ls -l --block-size=MB -rw------- pgsql pgsql 37MB Jul :
[pgsql@localhost ]$
对PostgreSQL中tablespace 与 database, table的理解的更多相关文章
- Postgresql中临时表(temporary table)的特性和用法
熟悉Oracle的人,相比对临时表(temporary table)并不陌生,很多场景对解决问题起到不错的作用,开源库Postgresql中,也有临时表的概念,虽然和Oracle中临时表名字相同,使用 ...
- HAWQ 官方文档创建filespace,tablespace,database,table
1.创建Filespace 创建Filespace必须是数据库超级用户( You must be a database superuser to create a filespace.)首先创建一个f ...
- Hive中的数据库(Database)和表(Table)
在前面的文章中,介绍了可以把Hive当成一个"数据库",它也具备传统数据库的数据单元,数据库(Database/Schema)和表(Table). 本文介绍一下Hive中的数据库( ...
- 在PostgreSQL中 pg_start_backup 做了什么?
# 在PostgreSQL中 pg_start_backup 做了什么?HM 2019-07-30 ## pg_start_backup 做一个备份开始标记,还做了一些其他的操作,下面进行探寻. * ...
- Postgresql实战经验之alter table 开小差了
Postgresql实战经验之alter table 开小差了 今天需要将一张有数据的表中一个字段varchar 类型转换为timestamp类型,但是pg的alter table 语句却开小差,出现 ...
- 通过arcgis在PostgreSQL中创建企业级地理数据库
部署环境: Win7 64位旗舰版 软件版本: PostgreSQL-9.1.3-2-windows-x64 Postgis-pg91x64-setup-2.0.6-1 Arcgis 10.1 SP1 ...
- 数据库中Schema和Database有什么区别
在MySQL中创建一个Schema好像就跟创建一个Database是一样的效果,在SQL Server和Orcal数据库中好像又不一样. 目前我只能理解,在mysql中 schema<==> ...
- PostgreSQL中关于关键字(保留字)在表名和字段名中的应用文件解决
标识符和关键词 受限标识符或被引号修饰的标识符.它是由双引号(")包围的一个任意字符序列.一个受限标识符总是一个标识符而不会是一个关键字.因此"select"可以用于引用 ...
- PostgreSQL 中日期类型转换与变量使用及相关问题
PostgreSQL中日期类型与字符串类型的转换方法 示例如下: postgres=# select current_date; date ------------ 2015-08-31 (1 row ...
随机推荐
- Windows Azure® 由世纪互联运营发布MySQL Database on Azure正式商用版
我们很高兴宣布MySQL Database on Azure于2015年9月1日在中国地区正式商用.回望过去,从2014年12月对少量用户开放的预览试用,到2015年4月30日对中国用户全面开放的公共 ...
- SwipeRefreshLayout的简要说明及使用demo
在最新的 Android Support Library, revision 19.1.0 (March 2014) 添加了SwipeRefreshLayout控件. 版本发布的说明信息如下: ...
- Kotlin 语言高级安卓开发入门
过去一年,使用 Kotlin 来为安卓开发的人越来越多.即使那些现在还没有使用这个语言的开发者,也会对这个语言的精髓产生共鸣,它给现在 Java 开发增加了简单并且强大的范式.Jake Wharton ...
- Hie with the Pie(POJ 3311状压dp)
题意:披萨店给n个地方送披萨,已知各地方(包括披萨店)之间花费的时间,求送完所有地方并回到店花费的最小时间 分析:状态好确定dp[i][j],i中1表示地方已送过,否则为0,j为当前状态最后一个送过的 ...
- KindEditor Asp.net
最近在使用KindEditor,其中遇到三个问题: 1.textarea添加 runat="server" 后整个editor在运行的时候不能显示出来,我没找到原因,于是我就把ru ...
- JQuery WEB前段开发
JQuery WEB前段开发 Jquery是继prototype之后又一个优秀的Javascript框架.它是轻量级的js库 ,它兼容CSS3,还兼容各种浏览器(IE 6.0+, FF 1.5+, S ...
- G-sensor驱动分析
重力传感器代码分析 重力传感器驱动的功能,主要是向HAL层提供IOCTRL接口,并通过input设备上报数据.芯片实际数据的读取是采用i2c协议读取原始数据,并且作为i2c设备挂载在系统上工作的. 1 ...
- well-posed problem and ill-posed problem
well-posed problem must have the property that A solution exists The solution is unique The solution ...
- [HIve - LanguageManual] LateralView
Lateral View Syntax Description Example Multiple Lateral Views Outer Lateral Views Lateral View Synt ...
- Oauth2 接口api
weibo:http://open.weibo.com/wiki/API weixin:http://mp.weixin.qq.com/wiki/home/index.html qq开发平台: 1 ...