mymeiyi commented on code in PR #604:
URL: https://github.com/apache/doris-website/pull/604#discussion_r1591722974


##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/transaction-load-manual.md:
##########
@@ -0,0 +1,376 @@
+---
+{
+    "title": "Transaction Load",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+事务是指一个操作,包含一个或多个SQL语句,这些语句的执行要么完全成功,要么完全失败,是一个不可分割的工作单位。
+
+## 显式事务和隐式事务
+
+### 显式事务
+
+显式事务需要用户主动的开启,提交或回滚事务。 在 Doris 中,提供了 2 种显式事务:
+
+1. 本文中介绍的事务写方式,即
+
+```sql
+begin; 
+[INSERT, UPDATE, DELETE statement]
+COMMIT; / ROLLBACK;
+```
+
+2. [Stream Load 2PC](load-atomicity.md#stream-load)
+
+### 隐式事务
+
+隐式事务是指用户在所执行的一条或多条SQL语句的前后,没有显式添加开启事务和提交事务的语句。
+
+在 Doris 中,除[Group 
Commit](group-commit-manual.md)外,每个导入语句在开始执行时都会开启一个事务,并且在该语句执行完成之后,自动提交该事务;或执行失败后,自动回滚该事务。更多详细信息请参考:
 [导入事务与原子性](load-atomicity.md)。
+
+## 事务操作
+
+### 开启事务
+
+```sql
+BEGIN;
+
+BEGIN WITH LABEL {user_label}; 
+```
+
+如果执行该语句时,当前 Session 正处于一个事务的中间过程,那么 Doris 会忽略该语句,也可以理解为事务是不能嵌套的。
+
+### 提交事务
+
+```sql 
+COMMIT;
+```
+
+用于提交在当前事务中进行的所有修改。
+
+### 回滚事务
+
+```sql
+ROLLBACK;
+```
+
+用于撤销当前事务的所有修改。
+
+事务是 Session 级别的,如果 Session 中止或关闭,也会自动回滚该事务。
+
+## 事务写入
+
+目前 Doris 中支持 2 种方式的事务写入。
+
+### 单表多次`INSERT INTO VALUES`写入
+
+假如表的结构为:
+
+```sql
+CREATE TABLE `dt` (
+    `id` int(11) NOT NULL,
+    `name` varchar(50) NULL,
+    `score` int(11) NULL
+) ENGINE=OLAP
+UNIQUE KEY(`id`)
+DISTRIBUTED BY HASH(`id`) BUCKETS 1
+PROPERTIES (
+    "replication_num" = "1"
+);
+```
+
+写入:
+
+```sql
+mysql> BEGIN;
+Query OK, 0 rows affected (0.01 sec)
+{'label':'txn_insert_b55db21aad7451b-b5b6c339704920c5', 'status':'PREPARE', 
'txnId':''}
+
+mysql> INSERT INTO dt (id, name, score) VALUES (1, "Emily", 25), (2, 
"Benjamin", 35), (3, "Olivia", 28), (4, "Alexander", 60), (5, "Ava", 17);
+Query OK, 5 rows affected (0.08 sec)
+{'label':'txn_insert_b55db21aad7451b-b5b6c339704920c5', 'status':'PREPARE', 
'txnId':'10013'}
+
+mysql> INSERT INTO dt VALUES (6, "William", 69), (7, "Sophia", 32), (8, 
"James", 64), (9, "Emma", 37), (10, "Liam", 64);
+Query OK, 5 rows affected (0.00 sec)
+{'label':'txn_insert_b55db21aad7451b-b5b6c339704920c5', 'status':'PREPARE', 
'txnId':'10013'}
+
+mysql> COMMIT;
+Query OK, 0 rows affected (1.02 sec)
+{'label':'txn_insert_b55db21aad7451b-b5b6c339704920c5', 'status':'VISIBLE', 
'txnId':'10013'}
+```
+
+这种写入方式不仅可以实现写入的原子性,而且在 Doris 中,能提升 `INSERT INTO VALUES` 的写入性能。

Review Comment:
   在fe内部攒批后走了stream load,是一个导入



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org
For additional commands, e-mail: dev-h...@doris.apache.org

Reply via email to