2025年9月25日: PostgreSQL 18 釋出!
支援的版本: 當前 (18) / 17 / 16 / 15 / 14 / 13
開發版本: devel
不支援的版本: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1

68.4. BKI命令 #

create tablename tableoid [bootstrap] [shared_relation] [rowtype_oid oid] (name1 = type1 [FORCE NOT NULL | FORCE NULL ] [, name2 = type2 [FORCE NOT NULL | FORCE NULL ], ...])

建立一個名為 tablename、OID 為 tableoid 的表,其列在括號中給出。

以下列型別由 bootstrap.c 直接支援: bool, bytea, char (1 位元組), name, int2, int4, regproc, regclass, regtype, text, oid, tid, xid, cid, int2vector, oidvector, _int4 (陣列), _text (陣列), _oid (陣列), _char (陣列), _aclitem (陣列)。雖然可以建立包含其他型別列的表,但這直到 pg_type 被建立並填充了適當條目後才能完成。(這實際上意味著只有這些列型別可以在引導目錄中使用,但非引導目錄可以包含任何內建型別。)

當指定 bootstrap 時,表僅在磁碟上建立;不會為它在 pg_classpg_attribute 等中寫入任何內容。因此,在手動(使用 insert 命令)新增這些條目之前,表將無法透過普通 SQL 操作訪問。此選項用於建立 pg_class 等自身。

如果指定了 shared_relation,則表將被建立為共享表。錶行型別 OID(pg_type OID)可以選擇透過 rowtype_oid 子句指定;如果未指定,則會自動為其生成一個 OID。(如果指定了 bootstrap,則 rowtype_oid 子句無用,但仍可提供以供文件記錄。)

open tablename

開啟名為 tablename 的表以插入資料。任何當前開啟的表都會被關閉。

close tablename

關閉已開啟的表。必須提供表名以進行交叉檢查。

insert ( [oid_value] value1 value2 ... )

使用 value1value2 等作為其列值,向已開啟的表插入新行。

NULL 值可以使用特殊關鍵字 _null_ 指定。看起來不像識別符號或數字字串的值必須用單引號括起來。(要在值中包含單引號,請寫兩次。字串中的反斜槓轉義也是允許的。)

declare [unique] index indexname indexoid on tablename using amname ( opclass1 name1 [, ...] )

在名為 tablename 的表上建立一個名為 indexname、OID 為 indexoid 的索引,使用 amname 訪問方法。要索引的欄位稱為 name1name2 等,相應的運算子類為 opclass1opclass2 等。此命令會建立索引檔案併為其建立相應的目錄條目,但不會初始化索引內容。

declare toast toasttableoid toastindexoid on tablename

為名為 tablename 的表建立一個 TOAST 表。TOAST 表被分配 OID toasttableoid,其索引被分配 OID toastindexoid。與 declare index 一樣,索引的填充被推遲。

build indices

填充先前已宣告的索引。

提交更正

如果您在文件中看到任何不正確、與您對特定功能的體驗不符或需要進一步說明的內容,請使用 此表單 報告文件問題。