本文共 8423 字,大约阅读时间需要 28 分钟。
首先,建立表:
pgsql=# create table tab10(id integer);CREATE TABLEpgsql=# 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=# \xExpanded display is on.pgsql=# select * from pg_type where typname='tab10';-[ RECORD 1 ]--+------------typname | tab10typnamespace | 2200typowner | 10typlen | -1typbyval | ftyptype | ctypcategory | Ctypispreferred | ftypisdefined | ttypdelim | ,typrelid | 188542typelem | 0typarray | 188543typinput | record_intypoutput | record_outtypreceive | record_recvtypsend | record_sendtypmodin | -typmodout | -typanalyze | -typalign | dtypstorage | xtypnotnull | ftypbasetype | 0typtypmod | -1typndims | 0typcollation | 0typdefaultbin | typdefault | pgsql=#
pgsql=# select * from pg_type where typname='_tab10';-[ RECORD 1 ]--+-----------typname | _tab10typnamespace | 2200typowner | 10typlen | -1typbyval | ftyptype | btypcategory | Atypispreferred | ftypisdefined | ttypdelim | ,typrelid | 0typelem | 188544typarray | 0typinput | array_intypoutput | array_outtypreceive | array_recvtypsend | array_sendtypmodin | -typmodout | -typanalyze | -typalign | dtypstorage | xtypnotnull | ftypbasetype | 0typtypmod | -1typndims | 0typcollation | 0typdefaultbin | typdefault | pgsql=#
创建一个表达式后,对其他的系统表的写入,也有很多
再看和pg_depend之间的关联:
pgsql=# drop table tab10;DROP TABLEpgsql=# 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 TABLEpgsql=# 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_typedepender object identity | tab10objsubid | 0referenced object class | pg_classreferenced object identity | tab10refobjsubid | 0dependency type | internal-[ RECORD 2 ]--------------+-------------depender object class | pg_typedepender object identity | tab10[]objsubid | 0referenced object class | pg_typereferenced object identity | tab10refobjsubid | 0dependency type | internal-[ RECORD 3 ]--------------+-------------depender object class | pg_classdepender object identity | tab10objsubid | 0referenced object class | pg_namespacereferenced object identity | 2200refobjsubid | 0dependency type | normalpgsql=#
再看对pg_class的影响:
pgsql=# drop table tab10;DROP TABLEpgsql=# create table tab10(id integer);CREATE TABLEpgsql=# \xExpanded display is on.pgsql=# select * from pg_class where relname='tab10';-[ RECORD 1 ]--+-------relname | tab10relnamespace | 2200reltype | 188562reloftype | 0relowner | 10relam | 0relfilenode | 188560reltablespace | 0relpages | 0reltuples | 0reltoastrelid | 0reltoastidxid | 0relhasindex | frelisshared | frelpersistence | prelkind | rrelnatts | 1relchecks | 0relhasoids | frelhaspkey | frelhasrules | frelhastriggers | frelhassubclass | frelfrozenxid | 2017relacl | reloptions | pgsql=#
再看对 pg_attribute的影响,生成表之后:
pgsql=# select 188563::regclass; regclass ---------- tab10(1 row)pgsql=# \xExpanded display is on.pgsql=# select * from pg_attribute where attrelid = (select max(attrelid) from pg_attribute);-[ RECORD 1 ]-+---------attrelid | 188563attname | tableoidatttypid | 26attstattarget | 0attlen | 4attnum | -7attndims | 0attcacheoff | -1atttypmod | -1attbyval | tattstorage | pattalign | iattnotnull | tatthasdef | fattisdropped | fattislocal | tattinhcount | 0attcollation | 0attacl | attoptions | -[ RECORD 2 ]-+---------attrelid | 188563attname | cmaxatttypid | 29attstattarget | 0attlen | 4attnum | -6attndims | 0attcacheoff | -1atttypmod | -1attbyval | tattstorage | pattalign | iattnotnull | tatthasdef | fattisdropped | fattislocal | tattinhcount | 0attcollation | 0attacl | attoptions | -[ RECORD 3 ]-+---------attrelid | 188563attname | xmaxatttypid | 28attstattarget | 0attlen | 4attnum | -5attndims | 0attcacheoff | -1atttypmod | -1attbyval | tattstorage | pattalign | iattnotnull | tatthasdef | fattisdropped | fattislocal | tattinhcount | 0attcollation | 0attacl | attoptions | -[ RECORD 4 ]-+---------attrelid | 188563attname | cminatttypid | 29attstattarget | 0attlen | 4attnum | -4attndims | 0attcacheoff | -1atttypmod | -1attbyval | tattstorage | pattalign | iattnotnull | tatthasdef | fattisdropped | fattislocal | tattinhcount | 0attcollation | 0attacl | attoptions | -[ RECORD 5 ]-+---------attrelid | 188563attname | xminatttypid | 28attstattarget | 0attlen | 4attnum | -3attndims | 0attcacheoff | -1atttypmod | -1attbyval | tattstorage | pattalign | iattnotnull | tatthasdef | fattisdropped | fattislocal | tattinhcount | 0attcollation | 0attacl | attoptions | -[ RECORD 6 ]-+---------attrelid | 188563attname | ctidatttypid | 27attstattarget | 0attlen | 6attnum | -1attndims | 0attcacheoff | -1atttypmod | -1attbyval | fattstorage | pattalign | sattnotnull | tatthasdef | fattisdropped | fattislocal | tattinhcount | 0attcollation | 0attacl | attoptions | -[ RECORD 7 ]-+---------attrelid | 188563attname | idatttypid | 23attstattarget | -1attlen | 4attnum | 1attndims | 0attcacheoff | -1atttypmod | -1attbyval | tattstorage | pattalign | iattnotnull | fatthasdef | fattisdropped | fattislocal | tattinhcount | 0attcollation | 0attacl | attoptions | pgsql=#
基本就是这些了。
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/p/3171433.html,如需转载请自行联系原作者