Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Mar 4, 2016
1 parent f18a7f5 commit 34cbe65
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 14 deletions.
11 changes: 0 additions & 11 deletions sharding-jdbc-doc/content/post/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,3 @@ weight = 8
### 不支持特殊`INSERT`
每条`INSERT`语句只能插入一条数据,不支持`VALUES`后有多行数据的语句
### 不支持`DISTINCT`聚合
### 对于`*`谨慎使用
一般情况下`SELECT`语句中是可以使用`*`的,如下的`SQL`可以正常在`Sharding-JDBC`中使用。
```sql
select * from order;
```
但以下几种SQL不允许使用`*`

- 语句中存在聚合函数`AVG`
- `GROUP BY`语句
- `ORDER BY`语句

2 changes: 1 addition & 1 deletion sharding-jdbc-doc/content/post/roadmap.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
date = "2016-01-08T16:14:21+08:00"
title = "未来线路规划"
weight = 10
weight = 11
+++
# 未来线路规划
1. 更加灵活和多维度的配置。包括spring支持,分片算法inline支持,读写分离配置,水平垂直分片配置,动态表配置等。
Expand Down
93 changes: 93 additions & 0 deletions sharding-jdbc-doc/content/post/sql_supported.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
+++
date = "2016-01-08T16:14:21+08:00"
title = "SQL支持详细列表"
weight = 9
+++

# SQL支持详细列表

由于`SQL`语法灵活复杂,分布式数据库和单机数据库的查询场景又不完全相同,难免有和单机数据库不兼容的`SQL`出现。
本文详细罗列出已明确可支持的`SQL`种类以及已明确不支持的`SQL`种类,尽量让使用者避免踩坑。
其中必然有未涉及到的`SQL`欢迎补充,未支持的`SQL`也尽量会在未来的版本中支持。

## 全局不支持项

### 动态表
未配置逻辑表和真实表对应关系的真实表,称为动态表。凡是动态表且未在`SQL``Hint`中包含分片键的`SQL`均不支持。
原因是未找到分片键则需全路由,但由于未配置逻辑表和真实表的对应关系,无法全路由。

### `DQL``DML`以外的语句
`Sharding-JDBC`定位于`CRUD`操作,目前仅针对`DQL``DML`语句进行支持。

### 子查询未详细测试

## 支持的SQL

### DQL

#### SELECT主语句

```sql
SELECT select_expr [, select_expr ...] FROM table_reference [, table_reference ...]
[WHERE where_condition]
[GROUP BY {col_name | position} [ASC | DESC]]
[ORDER BY {col_name | position} [ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
```

#### select_expr
```sql
* |
COLUMN_NAME [AS] [alias] |
(MAX | MIN | SUM | AVG)(COLUMN_NAME | alias) [AS] [alias] |
COUNT(* | COLUMN_NAME | alias) [AS] [alias]
```

#### table_reference
```sql
tbl_name [AS] alias] [index_hint_list] |
table_reference ([INNER] | {LEFT|RIGHT} [OUTER]) JOIN table_factor [JOIN ON conditional_expr | USING (column_list)] |
```

#### 示例

| SQL |
| ------------------------------------------------------------------------------------------------------- |
| SELECT * FROM tbl_name |
| SELECT * FROM tbl_name WHERE col1 = val1 ORDER BY col2 DESC LIMIT limit |
| SELECT COUNT(*), SUM(col1), MIN(col1), MAX(col1), AVG(col1) FROM tbl_name WHERE col1 = val1 |
| SELECT COUNT(col1) FROM tbl_name WHERE col2 = val2 GROUP BY col1 ORDER BY col3 DESC LIMIT offset, limit |
| SELECT * FROM tbl_name WHERE col1 = val1 OR col2 = val2 |

### DML

#### INSERT

| SQL | 无条件支持 | 必要条件 |
| ------------------------------------------------------------- | --------- | ------------------ |
| INSERT INTO tbl_name (col1, col2,...) VALUES (val1, val2,....)| `` | 插入列需要包含分片键 |
| INSERT INTO tbl_name VALUES (val1, val2,....) | `` | 通过`Hint`注入分片键 |

#### UPDATE

| SQL | 无条件支持 | 必要条件 |
| ------------------------------------------------------------- | --------- | ------------------ |
| UPDATE tbl_name SET col1 = val1 WHERE col2 = val2 || |

#### DELETE

| SQL | 无条件支持 | 必要条件 |
| ------------------------------------------------------------- | --------- | ------------------ |
| DELETE FROM tbl_name WHERE col1 = val1 || |

## 不支持的SQL

| SQL |
| ----------------------------------------------------------------------------------------------- |
| INSERT INTO tbl_name (col1, col2, ...) VALUES `(val1, val2,....), (val3, val4,....)` |
| INSERT INTO tbl_name (col1, col2, ...) `SELECT col1, col2, ... FROM tbl_name WHERE col3 = val3` |
| INSERT INTO tbl_name SET col1 = val1 |
| SELECT `DISTINCT` * FROM table_name WHERE column1 = value1 |
| SELECT COUNT(col1) as count_alias FROM tbl_name GROUP BY col1 `HAVING count_alias > val1` |
| SELECT * FROM tbl_name1 `UNION` SELECT * FROM tbl_name2 |
| SELECT * FROM tbl_name1 `UNION ALL` SELECT * FROM tbl_name2 |
2 changes: 1 addition & 1 deletion sharding-jdbc-doc/content/post/stress_test.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
date = "2016-01-08T16:14:21+08:00"
title = "压力测试报告"
weight = 9
weight = 10
chart = true
+++
# 压力测试报告
Expand Down
2 changes: 1 addition & 1 deletion sharding-jdbc-doc/content/post/transaction.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
date = "2016-01-29T16:14:21+08:00"
title = "事务支持说明"
weight = 11
weight = 12
+++
# 事务支持说明

Expand Down

0 comments on commit 34cbe65

Please sign in to comment.