Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql-compatibility: add doc for a UPDATE incompatibility case (#7781) #9464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mysql-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,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