@@ -23,38 +23,46 @@ HNSW (Hierarchical Navigating Small World) 是一种基于图的索引算法,
2323== 安装
2424[TIP]
2525====
26- 环境中已经安装了IvorySQL4.5及以上版本 ,安装路径为/usr/local/ivorysql/ivorysql-4
26+ 环境中已经安装了IvorySQL5及以上版本 ,安装路径为/usr/local/ivorysql/ivorysql-5
2727====
2828
2929=== 源码安装
3030
3131** 设置PG_CONFIG环境变量
32- ```
33- export PG_CONFIG=/usr/local/ivorysql/ivorysql-4/bin/pg_config
34- ```
32+ +
33+ [literal]
34+ ----
35+ export PG_CONFIG=/usr/local/ivorysql/ivorysql-5/bin/pg_config
36+ ----
3537
3638** 拉取pg_vector源码
37- ```
39+ +
40+ [literal]
41+ ----
3842git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git
39- ```
43+ ----
4044
4145** 安装 pgvector
42- ```
46+ +
47+ [literal]
48+ ----
4349cd pgvector
4450
4551sudo --preserve-env=PG_CONFIG make
4652sudo --preserve-env=PG_CONFIG make install
47- ```
53+ ----
4854
4955** 创建pgvector扩展
50- ```
51- [ivorysql@localhost ivorysql-4]$ psql
52- psql (17.5)
56+ +
57+ [literal]
58+ ----
59+ [ivorysql@localhost ivorysql-5]$ psql
60+ psql (18.0)
5361Type "help" for help.
5462
5563ivorysql=# create extension vector;
5664CREATE EXTENSION
57- ```
65+ ----
5866至此,pgvector扩展安装已完成。
5967更多用例,请参考 https://github.com/pgvector/pgvector?tab=readme-ov-file#getting-started[pgvector文档]
6068
@@ -66,7 +74,8 @@ CREATE EXTENSION
6674
6775=== 数据类型
6876
69- ```
77+ [literal]
78+ ----
7079ivorysql=# CREATE TABLE items5 (id bigserial PRIMARY KEY, name varchar2(20), num number(20), embedding bit(3));
7180CREATE TABLE
7281ivorysql=# INSERT INTO items5 (name, num, embedding) VALUES ('1st oracle data',0, '000'), ('2nd oracle data', 111, '111');
@@ -76,11 +85,12 @@ ivorysql=# SELECT * FROM items5 ORDER BY bit_count(embedding # '101') LIMIT 5;
7685----+-----------------+-----+-----------
7786 2 | 2nd oracle data | 111 | 111
7887 1 | 1st oracle data | 0 | 000
79- ```
88+ ----
8089
8190=== 匿名块
8291
83- ```
92+ [literal]
93+ ----
8494ivorysql=# declare
8595i vector(3) := '[1,2,3]';
8696begin
8999ivorysql-# /
90100NOTICE: [1,2,3]
91101DO
92- ```
102+ ----
93103
94104=== 存储过程(PROCEDURE)
95- ```
105+ [literal]
106+ ----
96107ivorysql=# CREATE OR REPLACE PROCEDURE ora_procedure()
97108AS
98109p vector(3) := '[4,5,6]';
@@ -104,10 +115,11 @@ CREATE PROCEDURE
104115ivorysql=# call ora_procedure();
105116NOTICE: [4,5,6]
106117CALL
107- ```
118+ ----
108119
109120==== 函数(FUNCTION)
110- ```
121+ [literal]
122+ ----
111123ivorysql=# CREATE OR REPLACE FUNCTION AddVector(a vector(3), b vector(3))
112124RETURN vector(3)
113125IS
@@ -121,4 +133,4 @@ ivorysql=# SELECT AddVector('[1,2,3]','[4,5,6]') FROM DUAL;
121133----------------
122134 [5,7,9]
123135(1 row)
124- ```
136+ ----
0 commit comments