首先,建立表:

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

查看此时的文件信息:

[pgsql@localhost ]$ pwd
/home/pgsql/DemoDir/base/[pgsql@localhost ]$ ls -l
-rw------- pgsql pgsql Jul :
[pgsql@localhost ]$

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

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

例如:pg_type。

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

pgsql=# select count(*) from pg_type;
count
-------
313
(1 row) pgsql=# create table tab10(id integer);
CREATE TABLE pgsql=# 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 classid
WHEN 'pg_class'::regclass THEN objid::regclass::text
WHEN 'pg_type'::regclass THEN objid::regtype::text
WHEN 'pg_proc'::regclass THEN objid::regprocedure::text
ELSE objid::text
END AS "depender object identity",
objsubid,
refclassid::regclass AS "referenced object class",
CASE refclassid
WHEN 'pg_class'::regclass THEN refobjid::regclass::text
WHEN 'pg_type'::regclass THEN refobjid::regtype::text
WHEN 'pg_proc'::regclass THEN refobjid::regprocedure::text
ELSE refobjid::text
END AS "referenced object identity",
refobjsubid,
CASE deptype
WHEN '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 classid
WHEN 'pg_class'::regclass THEN objid::regclass::text
WHEN 'pg_type'::regclass THEN objid::regtype::text
WHEN 'pg_proc'::regclass THEN objid::regprocedure::text
ELSE objid::text
END AS "depender object identity",
objsubid,
refclassid::regclass AS "referenced object class",
CASE refclassid
WHEN 'pg_class'::regclass THEN refobjid::regclass::text
WHEN 'pg_type'::regclass THEN refobjid::regtype::text
WHEN 'pg_proc'::regclass THEN refobjid::regprocedure::text
ELSE refobjid::text
END AS "referenced object identity",
refobjsubid,
CASE deptype
WHEN '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 | normal pgsql=#

再看对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=#

基本就是这些了。

PostgreSQL建表动作分析的更多相关文章

  1. PostgreSQL建表SQL语句写法

    DROP TABLE IF EXISTS bus; CREATE TABLE bus( id SERIAL PRIMARY KEY, mac ) NOT NULL UNIQUE, route int ...

  2. Activiti+oracle 启动项目时不能自动建表或更新表的问题分析及解决办法

    现象描述:按照正常配置,第一次启动时不能自动建表 关键配置片段如下: <bean id="processEngineConfiguration" class="or ...

  3. postgreSQL生成建表语句

    参考博文:https://blog.csdn.net/xiaofengtoo/article/details/84395199 修复了其函数中的bug,支持生成包含:字段(支持数组类型字段).约束.索 ...

  4. [转]Hibernate不能自动建表解决办法及Hibernate不同数据库的连接及SQL方言

    最近开始学Hibernate,看的是李刚的那本<轻量级java ee企业应用实战>.头一个hibernate程序,我原原本本的按照书上例子写下来,同时只是改动了些mysql的连接参数,并且 ...

  5. PostgreSQL的基础数据类型分析记录-转

    src:http://www.codeweblog.com/postgresql%E7%9A%84%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E ...

  6. 建表过程-列名&列类型&修改表B

    怎么建表? 主键 名称 重量 价格 生产日期 保质期 产地 种类                       分析:我们只要把第一行的表头建好后,这张表也就完成了.  术语:建表的过程就是声明字段过程 ...

  7. Hibernate不能自动建表解决办法

    最近开始学Hibernate,看的是李刚的那本<轻量级java ee企业应用实战>.头一个hibernate程序,我原原本本的按照书上例子写下来,同时只是改动了些mysql的连接参数,并且 ...

  8. hive建表没使用LZO存储格式,可是数据是LZO格式时遇到的问题

    今天微博大数据平台发邮件来说.他们有一个hql执行失败.可是从gateway上面的日志看不出来是什么原因导致的,我帮忙看了一下.最后找到了问题的解决办法,下面是分析过程: 1.执行失败的hql: IN ...

  9. [04] 利用注解生成实体类对应的建表sql语句

    1.实现功能 我们已经对注解有了基本的认识,知道了如何自定义注解,如何使用和最基本的处理注解. 本篇主要介绍,如何使用运行时级别的注解,配合反射来自动生成建表的sql语句.如下例: 我们有实体类Stu ...

随机推荐

  1. db2数据库sql报错信息

    sqlcode sqlstate 说明 000 00000 SQL语句成功完成   01xxx SQL语句成功完成,但是有警告 +012 01545 未限定的列名被解释为一个有相互关系的引用 +098 ...

  2. 【转】 CATransform3D 矩阵变换之立方体旋转实现细节

    原文网址:http://blog.csdn.net/ch_soft/article/details/7351896 第一部分.前几天做动画,使用到了CATransform3D ,由于没有学过计算机图形 ...

  3. 使用solrj操作solr索引库

    (solrj)初次使用solr的开发人员总是很郁闷,不知道如何去操作solr索引库,以为只能用<五分钟solr4.5教程(搭建.运行)>中讲到的用xml文件的形式提交数据到索引库,其实没有 ...

  4. Ajax+PHP简单入门教程

    Ajax 由 HTML.JavaScript™ 技术.DHTML 和 DOM 组成,这一杰出的方法可以将笨拙的 Web 界面转化成交互性的 Ajax 应用程序.对于Ajax,最核心的一个对象是XMLH ...

  5. git学习一

    一:Git是什么? Git是目前世界上最先进的分布式版本控制系统. 二:SVN与Git的最主要的区别? SVN是集中式版本控制系统,版本库是集中放在中央服务器的,而干活的时候,用的都是自己的电脑,所以 ...

  6. delphi7 开发布局

    delphi7界面布局(就是各种框框,代码管理器之类的东东)好了的,为什么以打开个新项目或者下次进入开发界面是环境的布局全部变了,如何才能锁定窗口布局? 在菜单栏最右边,有一个按钮save curre ...

  7. HDU 4325-Flowers(线段树+离散化)

    题意: 给出每个花开花的时间段,每询问一个时间点输出该时间点开花的数量 分析: 线段树的区间更新,单点查询,但发现时间很大,没法存区间,就想到了离散化. 离散化就是把要处理的数据统一起来重新标号. # ...

  8. 简单把webdriver的find_element方法写成函数

    __author__ = 'jyd' from selenium.webdriver.common.by import By #driver webdriver实例化对象 #element 查询元素的 ...

  9. QT4.7.4-vs2008和vs2010的安装并编写测试程序

    QT的安装着实费了我好大的劲,之前试过QT5.1.0与VS2010的安装,但是因为设置的地方太多,程序运行总是不成功,所以最后选用QT4.7.4和VS2008与VS2010来编写程序.写这篇文章来总结 ...

  10. Trail: JDBC(TM) Database Access(2)

    package com.oracle.tutorial.jdbc; import java.sql.CallableStatement; import java.sql.Connection; imp ...