PostpreSQL系統表中的字段

2021-08-21 12:10:43 字數 2066 閱讀 2918

每天學習一點點

select oid,relname,relkind from pg_class where relname like 'wpp_adefect_%' and length(relname) < 20

--17使用物件識別符號定位表名

select 6224742::regclass;

--18 ctid代表資料行在它所處的表的物理位置,vacuum full之後會變化。

--第乙個數字標識的是物理塊號,第二個數字是物理塊號中的行號。

select ctid,glass_id from wpp_adefect_glass_f limit 10;

--第十個物理塊第二行的內容是什麼?

select ctid,glass_id from wpp_adefect_glass_f where ctid = '(10,5)'--可以利用ctid刪除乙個table中重複的記錄,當然是大表用這種方式刪除才有意義,小表用此方法刪除就大材小用了。

select * from a t where t.ctid <> (select min(b.ctid) from --20180718 2000

--通過資料字典獲取表的字段資訊

--pg_attribute存放的是字段資訊,需要關聯 存放表的資料字典 pg_class & 存放schema的資料字典pg_namespace

select a.attname,pg_catalog.format_type(a.atttypid,a.atttypmod),a.attrelid as data_type  from pg_catalog.pg_attribute a

where a.attrelid in (select c.oid  from pg_catalog.pg_class c left join pg_catalog.pg_namespace n on n.oid = c.relnamespace

where c.relname = 'pg_class' and n.nspname = 'pg_catalog')

and a.attnum > 0 

and not a.attisdropped order by a.attnum

--使用regclass會簡化很多

select a.attname,pg_catalog.format_type(a.atttypid,a.atttypmod),a.attrelid as data_type  from pg_catalog.pg_attribute a

where a.attrelid = 'pg_catalog.pg_class'::regclass

and a.attnum > 0 

and not a.attisdropped order by a.attnum

--通過資料字典獲取表的分布鍵

create table acquire_dsitr(a int,b int, c int,d int) distributed by (c,a);

select * from gp_distribution_policy where localoid = 'acquire_dsitr'::regclass;

--這樣就可以關聯pg_attribute 來獲取分布鍵了

--attrnums 是乙個陣列。記錄欄位的attunm 與pg_attribute中的attnum關聯

select a.attrnums[i.i],b.attname,a.localoid::regclass from gp_distribution_policy a,

(select generate_series(1,100))i(i), pg_attribute b

where a.attrnums[i.i] is not null

and a.localoid = b.attrelid

and a.attrnums[i.i] = b.attnum

and a.localoid = 'acquire_dsitr'::regclass

order by i.ia b where t.ctid = b.ctid)

Windows系統呼叫中的系統服務表

windows核心分析索引目錄 windows系統呼叫中的系統服務表 如果這部分不理解,可以檢視 windows核心分析索引目錄依次閱讀。我們在之前講過系統呼叫過程中,給予eax乙個編號,作業系統通過這個編號來執行某個核心函式。這個函式是通過作業系統的系統服務表來查詢的。現在,我們來 一下nt ki...

pg表中的系統列

oid 物件id,預設是隱藏不顯示的,在建立表的時候使用了with oids會顯示這個列 select oid.from t test 錯誤 error column oid does not exist sql 狀態 42703 字元 8 create table t test id intege...

關於sqlite中系統表sqlite master

create table sqlite master type text name text tbl name text rootpage integer sql text 表 對於表來說,type字段永遠是 table name字段永遠是表的名字。所以,要獲得資料庫中所有表的列表,使用下列sele...