Skip to content

Commit b25c802

Browse files
Cliff57ketor
authored andcommitted
[docs] Add Chinese documentation for SQL operations
1 parent 9160b01 commit b25c802

File tree

5 files changed

+114
-20
lines changed

5 files changed

+114
-20
lines changed

docs/zh/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ DingoDB中文文档
22
===============
33

44
.. toctree::
5-
:maxdepth: 3
5+
:maxdepth: 5
66

77
概览/index
88
新手指南/index
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# SQL基本操作
2+
3+
DingoDB安装部署成功后,因为DingoDB兼容MySQL语义,您可以通过SQL工具或者MySQL客户端中连接DingoDB,并执行SQL语句。
4+
5+
## 1、创建表
6+
7+
### 1)参数说明
8+
|参数|说明|详情|语法|
9+
|:-:|:-|:-|:-|
10+
|Table Name|表名|表的名称,必须在数据库中唯一,并遵循命名规则。|Table table_name|
11+
|Replica|副本数|表的副本数量。|Replica = {replica}|
12+
|Autoincrement |自增字段|指定某字段为自增列,目前仅支持 `int` 类型,并可设置自增初始值。| Auto_increment|
13+
|Partition By|Range分区:按范围分区; |根据指定范围将数据划分到不同的分区中。可以根据某个列或多列的值进行范围分区。|Partition by range values (1,100),(101,200);|
14+
||Hash分区:按Key的Hash值分区;|通过对某列或多列的哈希值进行分区,每个哈希值确定数据所属分区。||
15+
|Engine|存储引擎|创建表时指定的存储引擎;Dingo 提供 LSM、BTree、Txn_LSM、Txn_BTree 四种存储引擎。 默认为:Txn_LSM|Engine = Txn_LSM;|
16+
|Index|向量索引|在向量字段上创建索引,索引类型需指定为 `VECTOR`|INDEX[index_name ]VECTOR( {index_parameters} )|
17+
||标量索引|在标量字段上创建的索引,默认索引类型为标量, `Scalar`可写可不写。|INDEX[ index_name ] (SCALAR)( {index_parameters} )|
18+
19+
### 2)SQL示例
20+
21+
* 创建一张带有标量索引的表;
22+
```sql
23+
CREATE TABLE saltable (
24+
id int,
25+
name varchar(32),
26+
age int,
27+
gmt bigint,
28+
price float,
29+
birthday date,
30+
create_time time,
31+
update_time timestamp,
32+
zip_code varchar(20),
33+
is_delete boolean,
34+
index name_index (name), //标量索引
35+
PRIMARY KEY (id)
36+
);
37+
```
38+
* 创建一张带有向量索引的表;
39+
```sql
40+
CREATE TABLE vectable (
41+
id bigint not null,
42+
name varchar(32),
43+
age int,
44+
amount double,
45+
birthday date,
46+
feature float array not null, //向量列
47+
feature_id bigint not null,
48+
index feature_index vector(feature_id, feature) parameters(type=hnsw, metricType=L2, dimension=8, efConstruction=40, nlinks=32),//向量索引
49+
PRIMARY KEY(id)
50+
);
51+
```
52+
*说明:*
53+
54+
创建语句中feature列为向量列,类型为浮点型数组,有向量列之后需要添加向量索引,如果不加向量索引会当做普通的数组类型,向量索引在定义时与标量索引类似,对应定义的方法使用VECTOR,需要的参数有两个一个是向量的id列,目前只支持整型,第二个参数是向量列,目前只有浮点型数组。
55+
56+
## 2、插入数据
57+
* 这里以‘vectable’为例,因为向量字段维度指定为8,所以插入时array数组中需要包含8个元素。
58+
```sql
59+
INSERT INTO vectable VALUES
60+
(1,'Alice',15,98.50,'1995-01-01',array[0.19151945412158966, 0.6221087574958801, 0.43772774934768677, 0.7853586077690125, 0.7799758315086365, 0.10310444235801697, 0.8023741841316223, 0.9455532431602478],1),
61+
(2,'Ben',15,99.00,'1995-03-15',array[0.3833174407482147, 0.053873684257268906, 0.45164841413497925, 0.9820047616958618, 0.12394270300865173,0.2764642536640167, 0.801872193813324, 0.9581393599510193],2),
62+
(3,'Joy',15,100.00,'1996-11-12',array[0.07534254342317581, 0.055006396025419235, 0.32319480180740356, 0.5904818177223206, 0.8538985848426819,0.5524689555168152, 0.2730432450771332, 0.9744951128959656],3),
63+
(4,'Jason',17,97.45,'1994-05-11',array[0.17446526885032654, 0.7370864748954773, 0.1270293891429901, 0.36964988708496094, 0.6043339967727661, 0.35782694816589355, 0.2128199338912964, 0.22331921756267548],4),
64+
(5,'Lily',16,99.50,'1997-05-19',array[0.18726634979248047, 0.797411322593689, 0.6123674511909485, 0.5556533932685852, 0.6294915676116943, 0.686180055141449, 0.24038253724575043,0.038164183497428894],5);
65+
```
66+
## 3、查询数据
67+
* 全表查询
68+
```sql
69+
SELECT * FROM vectable;
70+
```
71+
* 条件查询,使用`WHERE`条件语句,对数据进行条件筛选
72+
```sql
73+
SELECT * FROM Vectable WHERE name=‘Ben’;
74+
```
75+
## 4、修改数据
76+
使用`UPDATE TABLE`语句对表中数据进行修改
77+
```sql
78+
UPDATE vectable SET amount=95 WHERE id = 3;
79+
```
80+
## 5、删除表
81+
使用 `DROP TABLE`语句删除表
82+
```sql
83+
DROP TABLE vectable;
84+
```
85+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Windows安装
2+
===========
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
:glob:
7+
8+
快速入门.md

docs/zh/新手指南/快速入门.md renamed to docs/zh/新手指南/Windows安装/快速入门.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212

1313
在管理员模式下打开 PowerShell 或 Windows 命令提示符,方法是右键单击并选择“以管理员身份运行”,输入 wsl --install 命令,安装完成后重启计算机。此命令将启用运行 WSL 并安装 Linux 的 Ubuntu 发行版所需的功能。
1414

15-
![Wsl_install](../images/lite_dingo/dingo_install_wsl.png)
15+
![Wsl_install](../../images/lite_dingo/wsl_install.png)
1616

1717
### 3)重启电脑
1818

1919
重启计算机后会自动安装Linux子系统(默认是Ubuntu)。
2020

21-
![linux_install](../images/lite_dingo/ubuntu_install.png)
21+
![linux_install](../../images/lite_dingo/ubuntu_install.png)
2222

2323
### 4)检查系统配置
2424

2525
在控制面板->程序→启用或关闭 Windows 功能中检查是否勾选适用于 Linux 的 Windows 子系统和虚拟机平台。
2626

27-
![check_configuration](../images/lite_dingo/check_Windows_configuration.png)
27+
![check_configuration](../../images/lite_dingo/check_Windows_configuration.png)
2828

2929
### 5)设置用户名和密码
3030

@@ -48,15 +48,15 @@ b. 在 PowerShell 内的根级别打开 WSL 发行版后,可使用此命令更
4848

4949
c. 系统将提示你输入新的 UNIX 密码,然后确认该密码。 在被告知密码已成功更新后,请使用以下命令在 PowerShell 内关闭 WSL:exit。
5050

51-
![reset_password](../images/lite_dingo/reset_unix_passsword.png)
51+
![reset_password](../../images/lite_dingo/reset_unix_passsword.png)
5252

5353
### 6)检查WSL版本
5454

5555
在 PowerShell 或 Windows 命令提示符中输入以下命令来检查每个发行版的 WSL 版本,默认是 WSL 2。
5656

5757
> `wsl -l -v`
5858
59-
![wsl_version](../images/lite_dingo/wsl_version.png)
59+
![wsl_version](../../images/lite_dingo/wsl_version.png)
6060

6161
## 2、安装Docker DeskTop
6262

@@ -72,19 +72,19 @@ c. 系统将提示你输入新的 UNIX 密码,然后确认该密码。 在被
7272

7373
[Docker DeskTop下载](https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe?_gl=1*154qt9t*_ga*MTAyNTc0ODM4My4xNzE1MTUxNTE4*_ga_XJWPQMJYHQ*MTcxNTIzNDg5NC4zLjAuMTcxNTIzNDg5NC42MC4wLjA)
7474

75-
![docker_download](../images/lite_dingo/dockerDesk_download.png)
75+
![docker_download](../../images/lite_dingo/dockerDesk_download.png)
7676

77-
![docker_install](../images/lite_dingo/dockerDesk_install.png)
77+
![docker_install](../../images/lite_dingo/dockerDesk_install.png)
7878

79-
![dockerDeskTop](../images/lite_dingo/dockerDesktop.png)
79+
![dockerDeskTop](../../images/lite_dingo/dockerDesktop.png)
8080

8181
### 3)启动Docker DeskTop
8282

8383
安装完成。在启动Docker Desktop过程中,如果出现下述报错,可以在 Windows 设置中点击更新 Windows,更新后重启电脑可解决。
8484

85-
![dockerDesk_error](../images/lite_dingo/dockerdesk_error.png)
85+
![dockerDesk_error](../../images/lite_dingo/dockerdesk_error.png)
8686

87-
![windows_update](../images/lite_dingo/windows_update.png)
87+
![windows_update](../../images/lite_dingo/windows_update.png)
8888

8989
_**特别注意**_
9090

@@ -237,14 +237,14 @@ Docker desktop 和Ubuntu里的 docker不同不同,他有一套特殊的工作
237237

238238
### 6)运行部署脚本
239239
使用 powershell 运行脚本 deploy.ps1。
240-
![run_deploy](../images/lite_dingo/windows_run_deploy.ps1.png)
240+
![run_deploy](../../images/lite_dingo/windows_run_deploy.ps1.png)
241241

242242
### 7)查看进程
243243
- 通过Docker Tesktop 查看容器状态和资源使用情况。
244-
![docker](../images/lite_dingo/dockerDesktop.png)
244+
![docker](../../images/lite_dingo/dockerDesktop.png)
245245

246246
- 通过 localhost:22001或者127.0.0.1:22001 查看 Dingo-store 服务信息。
247-
![dingo_monitor](../images/lite_dingo/dingo_monitor.png)
247+
![dingo_monitor](../../images/lite_dingo/dingo_monitor.png)
248248

249249
## 4、开启DingoDB之旅
250250

@@ -253,16 +253,16 @@ Docker desktop 和Ubuntu里的 docker不同不同,他有一套特殊的工作
253253
### _DBeaver_
254254

255255
### 1)创建一个连接
256-
![dbeaver_connect](../images/lite_dingo/dbeaver_create_new_connection.png)
256+
![dbeaver_connect](../../images/lite_dingo/dbeaver_create_new_connection.png)
257257

258258
### 2)选择Mysql驱动
259-
![dingo_mysql](../images/lite_dingo/dbeaver_connect_dingodb.png)
259+
![dingo_mysql](../../images/lite_dingo/dbeaver_connect_dingodb.png)
260260

261261
### 3)配置连接参数
262-
![dingo_parameter](../images/lite_dingo/dbeaver_connect_dingodb_parameter.png)
262+
![dingo_parameter](../../images/lite_dingo/dbeaver_connect_dingodb_parameter.png)
263263

264264
### 4)测试链接
265-
![test_connection](../images/lite_dingo/dbeaver_testConnetion.png)
265+
![test_connection](../../images/lite_dingo/dbeaver_testConnetion.png)
266266

267267
### _Mysql客户端_
268268

docs/zh/新手指南/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
========
33

44
.. toctree::
5-
:maxdepth: 1
5+
:maxdepth: 3
66
:glob:
77

8-
快速入门.md
8+
Windows安装/index
9+
SQL基本操作.md

0 commit comments

Comments
 (0)