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自带的所有官方模块,用户可以根据需要进行安装和使用。