首先,建立表:

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. java后台调用HttpURLConnection类模拟浏览器请求(一般用于接口调用)

    项目开发中难免遇到外部接口的调用,小生今天初次接触该类,跟着API方法走了一遍,如有不对的地方,还请哆哆指正,拜谢! 1 package com.cplatform.movie.back.test; ...

  2. CentOS SVN服务器安装配置小记

    SVN的安装 安装很简单,尤其对于CentOS这种,直接: # yum install subversion# yum install mod_dav_svn 不同发行版的Package安装方法参见h ...

  3. ActionBarSherlock的学习笔记(三) ------------ ActionBarSherlock中的overflow及item的点击事件

    定义一个自定义的ActionBar的title,并添加一个overflow的Action   Item. 代码实现 如下  : import android.os.Bundle; import and ...

  4. <五>面向对象分析之UML核心元素之边界

    一:基本概念

  5. php mysql事务

    这里记录一下php操作mysql事务的一些知识 要知道,MySQL默认的行为是在每条SQL语句执行后执行一个COMMIT语句,从而有效的将每条语句独立为一个事务.但是,在使用事务时,是需要执行多条sq ...

  6. Oracle 存储过程动态建表

    动态sql,顾名思义就是动态执行的sql,也就是说在没执行之前是动态的拼接的. 任务 传入参数:新建的表名hd+当前的年和月,例如hd_201105表结构是:字段1:id ,类型是number,可以自 ...

  7. [Everyday Mathematics]20150113

    设 $f\in C^2(0,+\infty)$ 适合 $$\bex \lim_{x\to 0^+}f'(x)=-\infty,\quad \lim_{x\to 0^+}f''(x)=+\infty. ...

  8. SQL Server优化50法(转)

    虽然查询速度慢的原因很多,但是如果通过一定的优化,也可以使查询问题得到一定程度的解决. 查询速度慢的原因很多,常见如下几种: 没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷) I/ ...

  9. webdriver(python)学习笔记五——层级定位

    层级定位 在实际的项目测试中,经常会有这样的需求:页面上有很多个属性基本相同的元素,现在需要具体定位到其中的一个.由于属性基本相当,所以在定位的时候会有些麻烦,这时候就需要用到层级定位.先定位父元素, ...

  10. [Hive - LanguageManual] GroupBy

    Group By Syntax Simple Examples Select statement and group by clause Advanced Features Multi-Group-B ...