PostgreSQL官方擴展模組
PostgreSQL是一款功能強大的開源物件關係型資料庫系統,具備豐富的擴展模組來增強其功能。ServBay包含了PostgreSQL自帶的所有官方擴展模組,用戶可以輕鬆利用這些模組來滿足各種複雜的應用需求。以下是一些常用的PostgreSQL官方擴展模組及其簡要介紹。
常用擴展模組
1. pg_stat_statements
功能:收集和記錄SQL語句的執行統計資訊。
用途:幫助資料庫管理員分析和優化查詢效能。
安裝命令:
CREATE EXTENSION pg_stat_statements;
2. pg_trgm
功能:提供基於三元組(trigram)的字串相似度搜尋功能。
用途:用於模糊匹配、全文搜尋等場景。
安裝命令:
CREATE EXTENSION pg_trgm;
3. hstore
功能:提供鍵值對儲存功能。
用途:適用於需要儲存動態屬性的場景,如配置數據、元數據等。
安裝命令:
CREATE EXTENSION hstore;
4. citext
功能:提供大小寫不敏感的文本類型。
用途:用於需要大小寫不敏感比較的場景,如使用者名稱、電子郵件地址等。
安裝命令:
CREATE EXTENSION citext;
5. uuid-ossp
功能:生成UUID(通用唯一標識符)。
用途:用於需要唯一標識符的場景,如主鍵、會話ID等。
安裝命令:
CREATE EXTENSION "uuid-ossp";
6. intarray
功能:提供對整數數組的額外操作功能。
用途:適用於需要對整數數組進行複雜操作的場景。
安裝命令:
CREATE EXTENSION intarray;
7. btree_gin
功能:提供基於GIN索引的B樹操作支持。
用途:用於需要高效索引和查詢的場景。
安裝命令:
CREATE EXTENSION btree_gin;
8. btree_gist
功能:提供基於GiST索引的B樹操作支持。
用途:用於需要多維索引和複雜查詢的場景。
安裝命令:
CREATE EXTENSION btree_gist;
9. cube
功能:提供對多維數據的支持。
用途:適用於需要處理多維數據的場景,如數據倉庫、OLAP分析等。
安裝命令:
CREATE EXTENSION cube;
10. fuzzystrmatch
功能:提供字串模糊匹配功能。
用途:用於模糊搜尋、數據清洗等場景。
安裝命令:
CREATE EXTENSION fuzzystrmatch;
11. plpgsql
功能:PL/pgSQL過程語言支持。
用途:用於編寫存儲過程和觸發器。
安裝命令:
CREATE EXTENSION plpgsql;
12. tablefunc
功能:提供對表格函數的支持。
用途:用於交叉表查詢、數據透視等場景。
安裝命令:
CREATE EXTENSION tablefunc;
13. dblink
功能:提供跨資料庫連接功能。
用途:用於從一個資料庫查詢另一個資料庫的數據。
安裝命令:
CREATE EXTENSION dblink;
14. postgres_fdw
功能:提供對外部PostgreSQL資料庫的訪問功能。
用途:用於跨資料庫查詢和數據整合。
安裝命令:
CREATE EXTENSION postgres_fdw;
15. pgcrypto
功能:提供加密和解密功能。
用途:用於數據加密、雜湊等安全需求。
安裝命令:
CREATE EXTENSION pgcrypto;
安裝和使用擴展模組
在ServBay中,您可以通過以下步驟來安裝和使用PostgreSQL的官方擴展模組:
連接到PostgreSQL資料庫:
bashpsql -U your_username -d your_database
1安裝擴展模組:
sqlCREATE EXTENSION module_name;
1驗證安裝:
sql\dx
1
以下是啟用pg_trgm
的範例
psql (16.3 (ServBay))
Type "help" for help.
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
----------+---------+------------+------------------------------
pgcrypto | 1.3 | public | cryptographic functions
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(2 rows)
postgres=# CREATE EXTENSION pg_trgm;
CREATE EXTENSION
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
----------+---------+------------+-------------------------------------------------------------------
pg_trgm | 1.6 | public | text similarity measurement and index searching based on trigrams
pgcrypto | 1.3 | public | cryptographic functions
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(3 rows)
postgres=#
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
查詢PostgreSQL所附帶的模組
在ServBay中,你可以通過下面的命令,查看所附帶的PostgreSQL模組:
SELECT * FROM pg_available_extensions order by name;
一個典型的返回如下:
name | default_version | installed_version | comment
------------------------------+-----------------+-------------------+---------------------------------------------------------------------------------------------------------------------
address_standardizer | 3.4.2 | | Used to parse an address into constituent elements. Generally used to support geocoding address normalization step.
address_standardizer_data_us | 3.4.2 | | Address Standardizer US dataset example
adminpack | 2.1 | | administrative functions for PostgreSQL
amcheck | 1.3 | | functions for verifying relation integrity
autoinc | 1.0 | | functions for autoincrementing fields
bloom | 1.0 | | bloom access method - signature file based index
btree_gin | 1.3 | | support for indexing common datatypes in GIN
btree_gist | 1.7 | | support for indexing common datatypes in GiST
citext | 1.6 | | data type for case-insensitive character strings
cube | 1.5 | | data type for multidimensional cubes
dblink | 1.2 | | connect to other PostgreSQL databases from within a database
dict_int | 1.0 | | text search dictionary template for integers
dict_xsyn | 1.0 | | text search dictionary template for extended synonym processing
earthdistance | 1.1 | | calculate great-circle distances on the surface of the Earth
file_fdw | 1.0 | | foreign-data wrapper for flat file access
fuzzystrmatch | 1.2 | | determine similarities and distance between strings
hstore | 1.8 | | data type for storing sets of (key, value) pairs
insert_username | 1.0 | | functions for tracking who changed a table
intagg | 1.1 | | integer aggregator and enumerator (obsolete)
intarray | 1.5 | | functions, operators, and index support for 1-D arrays of integers
isn | 1.2 | | data types for international product numbering standards
lo | 1.1 | | Large Object maintenance
ltree | 1.2 | | data type for hierarchical tree-like structures
moddatetime | 1.0 | | functions for tracking last modification time
old_snapshot | 1.0 | | utilities in support of old_snapshot_threshold
pageinspect | 1.12 | | inspect the contents of database pages at a low level
pg_buffercache | 1.4 | | examine the shared buffer cache
pg_freespacemap | 1.2 | | examine the free space map (FSM)
pg_jieba | 1.1.1 | | a parser for full-text search of Chinese
pg_prewarm | 1.2 | | prewarm relation data
pg_stat_statements | 1.10 | | track planning and execution statistics of all SQL statements executed
pg_surgery | 1.0 | | extension to perform surgery on a damaged relation
pg_trgm | 1.6 | 1.6 | text similarity measurement and index searching based on trigrams
pg_visibility | 1.2 | | examine the visibility map (VM) and page-level visibility info
pg_walinspect | 1.1 | | functions to inspect contents of PostgreSQL Write-Ahead Log
pgcrypto | 1.3 | 1.3 | cryptographic functions
pgrouting | 3.6.2 | | pgRouting Extension
pgrowlocks | 1.2 | | show row-level locking information
pgstattuple | 1.5 | | show tuple-level statistics
plpgsql | 1.0 | 1.0 | PL/pgSQL procedural language
postgis | 3.4.2 | | PostGIS geometry and geography spatial types and functions
postgis_sfcgal | 3.4.2 | | PostGIS SFCGAL functions
postgis_tiger_geocoder | 3.4.2 | | PostGIS tiger geocoder and reverse geocoder
postgres_fdw | 1.1 | | foreign-data wrapper for remote PostgreSQL servers
refint | 1.0 | | functions for implementing referential integrity (obsolete)
seg | 1.4 | | data type for representing line segments or floating-point intervals
sslinfo | 1.2 | | information about SSL certificates
tablefunc | 1.0 | | functions that manipulate whole tables, including crosstab
tcn | 1.0 | | Triggered change notifications
tsm_system_rows | 1.0 | | TABLESAMPLE method which accepts number of rows as a limit
tsm_system_time | 1.0 | | TABLESAMPLE method which accepts time in milliseconds as a limit
unaccent | 1.1 | | text search dictionary that removes accents
vector | 0.7.0 | | vector data type and ivfflat and hnsw access methods
xml2 | 1.1 | | XPath querying and XSLT
zhparser | 2.2 | | a parser for full-text search of Chinese
(55 rows)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
通過這些擴展模組,您可以增強PostgreSQL的功能,滿足各種複雜的應用需求。ServBay包含了PostgreSQL自帶的所有官方模組,用戶可以根據需要進行安裝和使用。