Skip to content

Commit

Permalink
mysql-compatibility: add doc for a UPDATE incompatibility case (#7781) (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot committed May 13, 2022
1 parent 233d483 commit 6d3fea0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions mysql-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ TiDB 中的[信息统计](/statistics.md#手动收集)与 MySQL 中的有所不

详情参见 [`SELECT`](/sql-statements/sql-statement-select.md)

### `UPDATE` 语句

详情参见 [`UPDATE`](/sql-statements/sql-statement-update.md)

### 视图

TiDB 中的视图不可更新,不支持 `UPDATE``INSERT``DELETE` 等写入操作。
Expand Down
12 changes: 11 additions & 1 deletion sql-statements/sql-statement-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,17 @@ SELECT * FROM t1;

## MySQL 兼容性

`UPDATE` 语句与 MySQL 完全兼容。如发现任何兼容性差异,请在 GitHub 上提交 [issue](https://github.com/pingcap/tidb/issues/new/choose)
在计算表达式中的列时,TiDB 总使用原始的值。例如:

```sql
CREATE TABLE t (a int, b int);
INSERT INTO t VALUES (1,2);
UPDATE t SET a = a+1,b=a;
```

在 MySQL 中,`b` 列的值会被更新成 2,因为 `b` 列被设置为与 `a` 列相同,而 `a`(最初是 1)在同一条语句中被更新成了 2。

TiDB 遵守标准的 SQL 行为,这里将 `b` 列值更新成 1。

## 另请参阅

Expand Down

0 comments on commit 6d3fea0

Please sign in to comment.