From 73999feca7799bf3ede8d915de48ecb6b5ec4fe1 Mon Sep 17 00:00:00 2001 From: Stalary Date: Thu, 30 Jun 2022 08:11:59 +0800 Subject: [PATCH] [doc] mod alter-table-replace (#10324) Modify alter-table-replace to alter-table-replace-column, move alter-table-replace to data-definition-statements. --- docs/.vuepress/sidebar/en/docs.js | 3 +- docs/.vuepress/sidebar/zh-CN/docs.js | 3 +- .../advanced/alter-table/replace-table.md | 72 ------------------- .../Alter/ALTER-TABLE-REPLACE.md | 43 +++++++++-- .../advanced/alter-table/replace-table.md | 71 ------------------ .../Alter/ALTER-TABLE-REPLACE.md | 43 +++++++++-- 6 files changed, 74 insertions(+), 161 deletions(-) delete mode 100644 docs/en/docs/advanced/alter-table/replace-table.md delete mode 100644 docs/zh-CN/docs/advanced/alter-table/replace-table.md diff --git a/docs/.vuepress/sidebar/en/docs.js b/docs/.vuepress/sidebar/en/docs.js index 0e4b62df86..96613579e1 100644 --- a/docs/.vuepress/sidebar/en/docs.js +++ b/docs/.vuepress/sidebar/en/docs.js @@ -153,8 +153,7 @@ module.exports = [ directoryPath: "alter-table/", initialOpenGroupIndex: -1, children: [ - "schema-change", - "replace-table" + "schema-change" ], }, { diff --git a/docs/.vuepress/sidebar/zh-CN/docs.js b/docs/.vuepress/sidebar/zh-CN/docs.js index d94759c866..8b44b4565b 100644 --- a/docs/.vuepress/sidebar/zh-CN/docs.js +++ b/docs/.vuepress/sidebar/zh-CN/docs.js @@ -153,8 +153,7 @@ module.exports = [ directoryPath: "alter-table/", initialOpenGroupIndex: -1, children: [ - "schema-change", - "replace-table" + "schema-change" ], }, { diff --git a/docs/en/docs/advanced/alter-table/replace-table.md b/docs/en/docs/advanced/alter-table/replace-table.md deleted file mode 100644 index 13ad8d5cc4..0000000000 --- a/docs/en/docs/advanced/alter-table/replace-table.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -{ - "title": "Replace Table", - "language": "en" -} ---- - - - -# Replace Table - -In version 0.14, Doris supports atomic replacement of two tables. -This operation only applies to OLAP tables. - -For partition level replacement operations, please refer to [Temporary Partition Document](../partition/table-temp-partition.md) - -## Syntax - -``` -ALTER TABLE [db.]tbl1 REPLACE WITH tbl2 -[PROPERTIES('swap' = 'true')]; -``` - -Replace table `tbl1` with table `tbl2`. - -If the `swap` parameter is `true`, after replacement, the data in the table named `tbl1` is the data in the original `tbl2` table. The data in the table named `tbl2` is the data in the original table `tbl1`. That is, the data of the two tables are interchanged. - -If the `swap` parameter is `false`, after replacement, the data in the table named `tbl1` is the data in the original `tbl2` table. The table named `tbl2` is dropped. - -## Principle - -The replacement table function actually turns the following set of operations into an atomic operation. - -Suppose you want to replace table A with table B, and `swap` is `true`, the operation is as follows: - -1. Rename table B to table A. -2. Rename table A to table B. - -If `swap` is `false`, the operation is as follows: - -1. Drop table A. -2. Rename table B to table A. - -## Notice - -1. The `swap` parameter defaults to `true`. That is, the replacement table operation is equivalent to the exchange of two table data. -2. If the `swap` parameter is set to `false`, the replaced table (table A) will be dropped and cannot be recovered. -3. The replacement operation can only occur between two OLAP tables, and the table structure of the two tables is not checked for consistency. -4. The replacement operation will not change the original permission settings. Because the permission check is based on the table name. - -## Best Practices - -1. Atomic Overwrite Operation - - In some cases, the user wants to be able to rewrite the data of a certain table, but if it is dropped and then imported, there will be a period of time in which the data cannot be viewed. At this time, the user can first use the `CREATE TABLE LIKE` statement to create a new table with the same structure, import the new data into the new table, and replace the old table atomically through the replacement operation to achieve the goal. For partition level atomic overwrite operation, please refer to [Temporary partition document](../partition/table-temp-partition.md) diff --git a/docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md b/docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md index 32f38c5378..a0c1616e0b 100644 --- a/docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md +++ b/docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md @@ -1,11 +1,11 @@ --- { - "title": "ALTER-TABLE-REPLACE", + "title": "ALTER-TABLE-REPLACE-COLUMN", "language": "en" } --- - - -# 替换表 - -在 0.14 版本中,Doris 支持对两个表进行原子的替换操作。 该操作仅适用于 OLAP 表。 - -分区级别的替换操作,请参阅 [临时分区文档](../partition/table-tmp-partition.md) - -## 语法说明 - -```text -ALTER TABLE [db.]tbl1 REPLACE WITH TABLE tbl2 -[PROPERTIES('swap' = 'true')]; -``` - -将表 tbl1 替换为表 tbl2。 - -如果 `swap` 参数为 `true`,则替换后,名称为 `tbl1` 表中的数据为原 `tbl2` 表中的数据。而名称为 `tbl2` 表中的数据为原 `tbl1` 表中的数据。即两张表数据发生了互换。 - -如果 `swap` 参数为 `false`,则替换后,名称为 `tbl1` 表中的数据为原 `tbl2` 表中的数据。而名称为 `tbl2` 表被删除。 - -## 原理 - -替换表功能,实际上是将以下操作集合变成一个原子操作。 - -假设要将表 A 替换为表 B,且 `swap` 为 `true`,则操作如下: - -1. 将表 B 重名为表 A。 -2. 将表 A 重名为表 B。 - -如果 `swap` 为 `false`,则操作如下: - -1. 删除表 A。 -2. 将表 B 重名为表 A。 - -## 注意事项 - -1. `swap` 参数默认为 `true`。即替换表操作相当于将两张表数据进行交换。 -2. 如果设置 `swap` 参数为 `false`,则被替换的表(表A)将被删除,且无法恢复。 -3. 替换操作仅能发生在两张 OLAP 表之间,且不会检查两张表的表结构是否一致。 -4. 替换操作不会改变原有的权限设置。因为权限检查以表名称为准。 - -## 最佳实践 - -1. 原子的覆盖写操作 - - 某些情况下,用户希望能够重写某张表的数据,但如果采用先删除再导入的方式进行,在中间会有一段时间无法查看数据。这时,用户可以先使用 `CREATE TABLE LIKE` 语句创建一个相同结构的新表,将新的数据导入到新表后,通过替换操作,原子的替换旧表,以达到目的。分区级别的原子覆盖写操作,请参阅 [临时分区文档](../partition/table-tmp-partition.md)。 diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md index ebe8e1ab8e..cda6b472dc 100644 --- a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md +++ b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md @@ -1,11 +1,11 @@ --- { - "title": "ALTER-TABLE-REPLACE", + "title": "ALTER-TABLE-REPLACE-COLUMN", "language": "zh-CN" } --- -