日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

PostgreSQL建表动作分析

發(fā)布時間:2023/12/19 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PostgreSQL建表动作分析 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

首先,建立表:

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]$

此時,文件剛剛建立好,還是一個空文件

同時,可以看到,因?yàn)榻⒘艘粋€表,所以數(shù)據(jù)字典中有很多系統(tǒng)表被更新:

例如:pg_type。

這個確實(shí)有點(diǎn)超乎想象,因?yàn)槲也⑽丛黾尤魏蔚男聇ype。

?

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=#

創(chuàng)建一個表達(dá)式后,對其他的系統(tǒng)表的寫入,也有很多

再看和pg_depend之間的關(guān)聯(lián):

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=#

基本就是這些了。

總結(jié)

以上是生活随笔為你收集整理的PostgreSQL建表动作分析的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。