PostgreSQL建表动作分析

首先,建立表:

pgsql=# create table tab10(id integer);
CREATE TABLE
pgsql=# select 147525::regclass;regclass 
----------
 tab10
(1 row)pgsql=# 

查看此时的文件信息:

[pgsql@localhost 16384]$ pwd
/home/pgsql/DemoDir/base/16384[pgsql@localhost 16384]$ ls -l 147525
-rw------- 1 pgsql pgsql 0 Jul  4 13:45 147525
[pgsql@localhost 16384]$ 

此时,文件刚刚建立好,还是一个空文件

同时,可以看到,因为建立了一个表,所以数据字典中有很多系统表被更新:

例如:pg_type。

这个确实有点超乎想象,因为我并未增加任何的新type。

 

pgsql=# select count(*) from pg_type;count 
-------313
(1 row)pgsql=# create table tab10(id integer);
CREATE TABLEpgsql=# select count(*) from pg_type;count 
-------315
(1 row)

看看增加了什么:

pgsql=# \x
Expanded display is on.
pgsql=# select * from pg_type where typname='tab10';
-[ RECORD 1 ]--+------------
typname        | tab10
typnamespace   | 2200
typowner       | 10
typlen         | -1
typbyval       | f
typtype        | c
typcategory    | C
typispreferred | f
typisdefined   | t
typdelim       | ,
typrelid       | 188542
typelem        | 0
typarray       | 188543
typinput       | record_in
typoutput      | record_out
typreceive     | record_recv
typsend        | record_send
typmodin       | -
typmodout      | -
typanalyze     | -
typalign       | d
typstorage     | x
typnotnull     | f
typbasetype    | 0
typtypmod      | -1
typndims       | 0
typcollation   | 0
typdefaultbin  | 
typdefault     | pgsql=# 
pgsql=# select * from pg_type where typname='_tab10';
-[ RECORD 1 ]--+-----------
typname        | _tab10
typnamespace   | 2200
typowner       | 10
typlen         | -1
typbyval       | f
typtype        | b
typcategory    | A
typispreferred | f
typisdefined   | t
typdelim       | ,
typrelid       | 0
typelem        | 188544
typarray       | 0
typinput       | array_in
typoutput      | array_out
typreceive     | array_recv
typsend        | array_send
typmodin       | -
typmodout      | -
typanalyze     | -
typalign       | d
typstorage     | x
typnotnull     | f
typbasetype    | 0
typtypmod      | -1
typndims       | 0
typcollation   | 0
typdefaultbin  | 
typdefault     | pgsql=# 

创建一个表达式后,对其他的系统表的写入,也有很多

再看和pg_depend之间的关联:

pgsql=# drop table tab10;
DROP TABLE
pgsql=# 
pgsql=# SELECT classid::regclass AS "depender object class",CASE classidWHEN 'pg_class'::regclass THEN objid::regclass::textWHEN 'pg_type'::regclass THEN objid::regtype::textWHEN 'pg_proc'::regclass THEN objid::regprocedure::textELSE objid::text END AS "depender object identity",objsubid,refclassid::regclass AS "referenced object class",CASE refclassidWHEN 'pg_class'::regclass THEN refobjid::regclass::textWHEN 'pg_type'::regclass THEN refobjid::regtype::textWHEN 'pg_proc'::regclass THEN refobjid::regprocedure::textELSE refobjid::textEND AS "referenced object identity",refobjsubid,CASE deptypeWHEN 'p' THEN 'pinned'WHEN 'i' THEN 'internal'WHEN 'a' THEN 'automatic'WHEN 'n' THEN 'normal'END AS "dependency type"
FROM pg_catalog.pg_depend 
WHERE objid >= 16384 OR refobjid >= 16384;
(No rows)
pgsql=# 
pgsql=# create table tab10(id integer);
CREATE TABLE
pgsql=# SELECT classid::regclass AS "depender object class",CASE classidWHEN 'pg_class'::regclass THEN objid::regclass::textWHEN 'pg_type'::regclass THEN objid::regtype::textWHEN 'pg_proc'::regclass THEN objid::regprocedure::textELSE objid::text END AS "depender object identity",objsubid,refclassid::regclass AS "referenced object class",CASE refclassidWHEN 'pg_class'::regclass THEN refobjid::regclass::textWHEN 'pg_type'::regclass THEN refobjid::regtype::textWHEN 'pg_proc'::regclass THEN refobjid::regprocedure::textELSE refobjid::textEND AS "referenced object identity",refobjsubid,CASE deptypeWHEN 'p' THEN 'pinned'WHEN 'i' THEN 'internal'WHEN 'a' THEN 'automatic'WHEN 'n' THEN 'normal'END AS "dependency type"
FROM pg_catalog.pg_depend 
WHERE objid >= 16384 OR refobjid >= 16384;
-[ RECORD 1 ]--------------+-------------
depender object class      | pg_type
depender object identity   | tab10
objsubid                   | 0
referenced object class    | pg_class
referenced object identity | tab10
refobjsubid                | 0
dependency type            | internal
-[ RECORD 2 ]--------------+-------------
depender object class      | pg_type
depender object identity   | tab10[]
objsubid                   | 0
referenced object class    | pg_type
referenced object identity | tab10
refobjsubid                | 0
dependency type            | internal
-[ RECORD 3 ]--------------+-------------
depender object class      | pg_class
depender object identity   | tab10
objsubid                   | 0
referenced object class    | pg_namespace
referenced object identity | 2200
refobjsubid                | 0
dependency type            | normalpgsql=# 

再看对pg_class的影响:

pgsql=# drop table tab10;
DROP TABLEpgsql=# create table tab10(id integer);
CREATE TABLEpgsql=# \x
Expanded display is on.
pgsql=# select * from pg_class where relname='tab10';
-[ RECORD 1 ]--+-------
relname        | tab10
relnamespace   | 2200
reltype        | 188562
reloftype      | 0
relowner       | 10
relam          | 0
relfilenode    | 188560
reltablespace  | 0
relpages       | 0
reltuples      | 0
reltoastrelid  | 0
reltoastidxid  | 0
relhasindex    | f
relisshared    | f
relpersistence | p
relkind        | r
relnatts       | 1
relchecks      | 0
relhasoids     | f
relhaspkey     | f
relhasrules    | f
relhastriggers | f
relhassubclass | f
relfrozenxid   | 2017
relacl         | 
reloptions     | pgsql=# 

 再看对 pg_attribute的影响,生成表之后:

pgsql=# select 188563::regclass;regclass 
----------
 tab10
(1 row)pgsql=# \x
Expanded display is on.
pgsql=# select * from pg_attribute where attrelid = (select max(attrelid) from pg_attribute);
-[ RECORD 1 ]-+---------
attrelid      | 188563
attname       | tableoid
atttypid      | 26
attstattarget | 0
attlen        | 4
attnum        | -7
attndims      | 0
attcacheoff   | -1
atttypmod     | -1
attbyval      | t
attstorage    | p
attalign      | i
attnotnull    | t
atthasdef     | f
attisdropped  | f
attislocal    | t
attinhcount   | 0
attcollation  | 0
attacl        | 
attoptions    | 
-[ RECORD 2 ]-+---------
attrelid      | 188563
attname       | cmax
atttypid      | 29
attstattarget | 0
attlen        | 4
attnum        | -6
attndims      | 0
attcacheoff   | -1
atttypmod     | -1
attbyval      | t
attstorage    | p
attalign      | i
attnotnull    | t
atthasdef     | f
attisdropped  | f
attislocal    | t
attinhcount   | 0
attcollation  | 0
attacl        | 
attoptions    | 
-[ RECORD 3 ]-+---------
attrelid      | 188563
attname       | xmax
atttypid      | 28
attstattarget | 0
attlen        | 4
attnum        | -5
attndims      | 0
attcacheoff   | -1
atttypmod     | -1
attbyval      | t
attstorage    | p
attalign      | i
attnotnull    | t
atthasdef     | f
attisdropped  | f
attislocal    | t
attinhcount   | 0
attcollation  | 0
attacl        | 
attoptions    | 
-[ RECORD 4 ]-+---------
attrelid      | 188563
attname       | cmin
atttypid      | 29
attstattarget | 0
attlen        | 4
attnum        | -4
attndims      | 0
attcacheoff   | -1
atttypmod     | -1
attbyval      | t
attstorage    | p
attalign      | i
attnotnull    | t
atthasdef     | f
attisdropped  | f
attislocal    | t
attinhcount   | 0
attcollation  | 0
attacl        | 
attoptions    | 
-[ RECORD 5 ]-+---------
attrelid      | 188563
attname       | xmin
atttypid      | 28
attstattarget | 0
attlen        | 4
attnum        | -3
attndims      | 0
attcacheoff   | -1
atttypmod     | -1
attbyval      | t
attstorage    | p
attalign      | i
attnotnull    | t
atthasdef     | f
attisdropped  | f
attislocal    | t
attinhcount   | 0
attcollation  | 0
attacl        | 
attoptions    | 
-[ RECORD 6 ]-+---------
attrelid      | 188563
attname       | ctid
atttypid      | 27
attstattarget | 0
attlen        | 6
attnum        | -1
attndims      | 0
attcacheoff   | -1
atttypmod     | -1
attbyval      | f
attstorage    | p
attalign      | s
attnotnull    | t
atthasdef     | f
attisdropped  | f
attislocal    | t
attinhcount   | 0
attcollation  | 0
attacl        | 
attoptions    | 
-[ RECORD 7 ]-+---------
attrelid      | 188563
attname       | id
atttypid      | 23
attstattarget | -1
attlen        | 4
attnum        | 1
attndims      | 0
attcacheoff   | -1
atttypmod     | -1
attbyval      | t
attstorage    | p
attalign      | i
attnotnull    | f
atthasdef     | f
attisdropped  | f
attislocal    | t
attinhcount   | 0
attcollation  | 0
attacl        | 
attoptions    | pgsql=# 

基本就是这些了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/462338.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

http 断点续传,Windows下HTTP方式单线程下载

http 断点续传www.diybl.com 时间 : 2011-05-20 作者:匿名 编辑:hawk 点击: 1128 [ 评论 ]-- 原理: 1. 打开本地文件fopen,移动文件指针到文件尾fseek 2. 获得文件大小ftell, 格式化HTTP请求头 &…

给创业者的30条建议

http://www.cocoachina.com/programmer/20150206/11119.html 去年年底的时候,我(Firstround Review 主编)在 Facebook 公司的咖啡厅里和 Caryn Marooney 交流着创业公司应该注意些什么事情。Caryn Marooney 现在是 Facebook 公司科技交流部门…

php swoole websocket vue 实现聊天室案例

代码地址: https://github.com/9499574/demo_chat_room 转载于:https://www.cnblogs.com/phper8/p/11017892.html

数据结构 练习21-trie的原理分析和应用

前言 今天具体分析一下trie树,包括:原理分析,应用场合,复杂度分析,与hash的比较,源码展现。大部分内容来自互联网,文中会注明出处。 原理分析 主要是hash树的变种,先看下图&#xff…

在辞职后的旅途中:我写了个App 创立了一家公司

http://www.cocoachina.com/programmer/20150206/11119.html 英文原文:How I built a startup while traveling to 20 countries 一年前,我离开了旧金山,变卖或者送掉了一切我所拥有的东西,然后买了一只 40 升的登山包。 我旅行到…

Android找工作系列之自定义View

...转载于:https://www.cnblogs.com/hbolin/p/11019959.html

POJ 1088-滑雪

矩阵里的数字代表当前点的高度,只能从高的点滑到低的点,求最长能滑的距离。初始点 不规定。我们可以向每个点的四周搜索,能走则就在当前距离加1。并将已经求的值保存在 二维数组中。(记忆化搜索) /*Accepted 252K …

PostgreSQL的 initdb 源代码分析之二十一

继续分析: setup_schema(); 展开: 实质就是创建info_schema。 cmd 是: "/home/pgsql/project/bin/postgres" --single -F -O -c search_pathpg_catalog -c exit_on_errortrue -j template1 >/dev/null infor_schem_file是&…

Be My Eyes app:我是你的眼

http://www.cocoachina.com/industry/20150122/10979.html Be My Eyes是丹麦软件工作室Robocat为一家同名非营利性企业推出的一款应用,主要通过视频聊天的方式将志愿者和视力受损的患者联系起来,从而实现远程协助的功能。 Be My Eyes的核心概念非常简单-…

C#面试题整理(不带答案)

1.维护数据库的完整性、一致性、你喜欢用触发器还是自写业务逻辑?为什么? 2.什么是事务?什么是锁? 3.什么是索引,有什么优点? 4.视图是什么?游标是什么? 5.什么是存储过程?有什么优…

nRF905

nRF905[1]无线芯片是有挪威NORDIC公司出品的低于1GHz无线数传芯片,主要工作于433MHz、868MHz和915MHz的ISM频段。芯片内置频率合成器、功率放大器、晶体振荡器和调制器等功能模块,输出功率和通信频道可通过程序进行配置。非常适合于低功耗、低成本的系统…

用户界面概述

视图是提供了良好定义的功能集合的内容区域。 控件则是能够触发即时动作或可视化结果的图形对象 无论是什么类型的应用程序,都有一个应用程序窗口,该窗口为您提供了一个能够呈现应用程序的所有信息的背景。但是用户对这个窗口没有概念,他们对…

Firefox for iOS现身Github 使用Swift编写

http://www.cocoachina.com/industry/20141208/10545.html 自从Mozilla新CEO走马上任以来,该公司对于发展路线显然与以往有所不同,对该公司最重要的产品Firefox浏览器来说,也有了很多大的改变,包括前几天Mozilla宣布,它…

UVA 213 Message Decoding

题目链接:https://vjudge.net/problem/UVA-213 题目翻译摘自《算法禁赛入门经典》 题目大意 考虑下面的 01 串序列:  0, 00, 01, 10, 000, 001, 010, 011, 100, 101, 110, 0000, 0001, …, 1101, 1110, 00000, …  首先是长度为 1 的串,然…

The Event System

The Event System 在Qt中,事件是继承了虚拟类QEvent的对象,它代表了程序所发生的事情或者程序需要知道的一个外部活动的结果。事件可以被任意 QObject子类的实例接收和处理,是与widgets密切相关。本文描述了在一个典型的程序中事件是如何被传…

分组取最新记录的SQL

常遇到这样的情况,要取得所有客户的最新交易记录,读取网站所有浏览者最后一次访问时间。一个客户只读取最新的一次记录,相同,大部分的人首先想 到的就是排除所有记录,相同的只取一条。用distint,但是distint只能取到一…

g++参数介绍

地址:http://www.cnblogs.com/lidan/archive/2011/05/25/2239517.html [介绍] gcc and g分别是gnu的c & c编译器 gcc/g在执行编译工作的时候,总共需要4步 1.预处理,生成.i的文件 预处理器cpp 2.将预处理后的文件不转换成汇编语言,生成文件.s 编译器e…

利用CVE-2019-1040 - 结合RCE和Domain Admin的中继漏洞

0x00 前言 在本周之前,微软发布了针对CVE-2019-1040的补丁,这是一个允许绕过NTLM身份验证中继攻击的漏洞。这个漏洞是由Marina Simakov和Yaron Zinar(以及微软咨询公司的其他几位成员)发现的,他们在这里发表了一篇关于…

URL 学习总结

1、绝对路径(以"/"斜线开头的路径,代表相对于当前Web应用): a)地址给服务器用,web应用名称可以省略。 请求包含:request.getRequestDispatcher("/index.jsp").include(request, r…

[转]DEV界面

DevExpress控件使用经验总结 DevExpress是一个比较有名的界面控件套件,提供了一系列的界面控件套件的DotNet界面控件。本文主要介绍我在使用DevExpress控件过程中,遇到或者发现的一些问题解决方案,或者也可以所示一些小的经验总结。总体来讲&…