This is an automated email from the ASF dual-hosted git repository.
jiafengzheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 70642e3bff [Doc] 添加CTAS文档 (#9454)
70642e3bff is described below
commit 70642e3bff08fa24769df6f130f70df0350f1513
Author: Stalary <[email protected]>
AuthorDate: Tue May 10 09:01:42 2022 +0800
[Doc] 添加CTAS文档 (#9454)
* ADD: 添加CTAS文档
---
docs/.vuepress/sidebar/en.js | 1 +
docs/.vuepress/sidebar/zh-CN.js | 1 +
.../Create/CREATE-TABLE-AS-SELECT.md | 74 ++++++++++++++++++++++
.../Create/CREATE-TABLE-AS-SELECT.md | 74 ++++++++++++++++++++++
4 files changed, 150 insertions(+)
diff --git a/docs/.vuepress/sidebar/en.js b/docs/.vuepress/sidebar/en.js
index a7e92973fa..74b6f2f163 100644
--- a/docs/.vuepress/sidebar/en.js
+++ b/docs/.vuepress/sidebar/en.js
@@ -636,6 +636,7 @@ module.exports = [
"CREATE-RESOURCE",
"CREATE-SQL-BLOCK-RULE",
"CREATE-TABLE-LIKE",
+ "CREATE-TABLE-AS-SELECT",
"CREATE-TABLE",
"CREATE-VIEW",
"CREATE-EXTERNAL-TABLE",
diff --git a/docs/.vuepress/sidebar/zh-CN.js b/docs/.vuepress/sidebar/zh-CN.js
index 5298966b2c..9cac47e942 100644
--- a/docs/.vuepress/sidebar/zh-CN.js
+++ b/docs/.vuepress/sidebar/zh-CN.js
@@ -636,6 +636,7 @@ module.exports = [
"CREATE-RESOURCE",
"CREATE-SQL-BLOCK-RULE",
"CREATE-TABLE-LIKE",
+ "CREATE-TABLE-AS-SELECT",
"CREATE-TABLE",
"CREATE-VIEW",
"CREATE-EXTERNAL-TABLE",
diff --git
a/docs/en/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md
b/docs/en/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md
new file mode 100644
index 0000000000..2c40305867
--- /dev/null
+++
b/docs/en/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md
@@ -0,0 +1,74 @@
+---
+{
+ "title": "CREATE-TABLE-AS-SELECT",
+ "language": "en"
+}
+---
+
+<!--
+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.
+-->
+
+## CREATE-TABLE-AS-SELECT
+
+### Name
+
+CREATE TABLE AS SELECT
+
+### Description
+
+This statement creates the table structure by returning the results from the
Select statement and imports the data at the same time
+
+grammar:
+
+```sql
+CREATE TABLE table_name [( column_name_list )]
+opt_engine opt_partition opt_properties KW_AS query_stmt
+ ```
+
+illustrate:
+
+- Fields of type`decimal`are not currently supported
+- The user needs to have`SELECT`permission for the source table
and`CREATE`permission for the target database
+- After a table is created, data is imported. If the import fails, the table
is deleted
+
+### Example
+
+1. Using the field names in the SELECT statement
+
+ ```sql
+ create table `test`.`select_varchar`
+ PROPERTIES(\"replication_num\" = \"1\")
+ as select * from `test`.`varchar_table`
+ ```
+
+2. Custom field names (need to match the number of fields returned)
+ ```sql
+ create table `test`.`select_name`(user, testname, userstatus)
+ PROPERTIES(\"replication_num\" = \"1\")
+ as select vt.userId, vt.username, jt.status
+ from `test`.`varchar_table` vt join
+ `test`.`join_table` jt on vt.userId=jt.userId
+ ```
+
+### Keywords
+
+ CREATE, TABLE, AS, SELECT
+
+### Best Practice
+
diff --git
a/docs/zh-CN/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md
b/docs/zh-CN/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md
new file mode 100644
index 0000000000..21f15a3a8b
--- /dev/null
+++
b/docs/zh-CN/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md
@@ -0,0 +1,74 @@
+---
+{
+ "title": "CREATE-TABLE-AS-SELECT",
+ "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.
+-->
+
+## CREATE-TABLE-AS-SELECT
+
+### Name
+
+CREATE TABLE AS SELECT
+
+### Description
+
+该语句通过 Select 语句返回结果创建表结构,同时导入数据
+
+语法:
+
+```sql
+CREATE TABLE table_name [( column_name_list )]
+opt_engine opt_partition opt_properties KW_AS query_stmt
+ ```
+
+说明:
+
+- 暂时不支持`decimal`类型的字段
+- 用户需要拥有来源表的`SELECT`权限和目标库的`CREATE`权限
+- 创建表成功后,会进行数据导入,如果导入失败,将会删除表
+
+### Example
+
+1. 使用 select 语句中的字段名
+
+ ```sql
+ create table `test`.`select_varchar`
+ PROPERTIES(\"replication_num\" = \"1\")
+ as select * from `test`.`varchar_table`
+ ```
+
+2. 自定义字段名(需要与返回结果字段数量一致)
+ ```sql
+ create table `test`.`select_name`(user, testname, userstatus)
+ PROPERTIES(\"replication_num\" = \"1\")
+ as select vt.userId, vt.username, jt.status
+ from `test`.`varchar_table` vt join
+ `test`.`join_table` jt on vt.userId=jt.userId
+ ```
+
+### Keywords
+
+ CREATE, TABLE, AS, SELECT
+
+### Best Practice
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]