Tartarus0zm commented on code in PR #23060:
URL: https://github.com/apache/flink/pull/23060#discussion_r1276309785


##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -557,6 +558,58 @@ INSERT INTO my_ctas_table SELECT id, name, age FROM 
source_table WHERE mod(id, 1
 
 {{< top >}}
 
+## [CREATE OR] REPLACE TABLE
+```sql
+[CREATE OR] REPLACE TABLE [catalog_name.][db_name.]table_name
+[COMMENT table_comment]
+WITH (key1=val1, key2=val2, ...)
+AS select_query
+```
+Tables can also be replaced(or created) and populated by the results of a 
query in one replace-table-as-select (RTAS) statement.  RTAS is the simplest 
and fastest way to replace and insert data into a table with a single command.
+
+There are two parts in RTAS: the SELECT part can be any [SELECT query]({{< ref 
"docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL, the `[CREATE 
OR] REPLACE` part takes the resulting schema from the `SELECT` part and replace 
the target table. Similar to `CREATE TABLE` and `CTAS`, RTAS requires the 
required options of the target table must be specified in WITH clause.
+
+Consider the example statement below:
+
+```sql
+REPLACE TABLE my_rtas_table
+WITH (
+    'connector' = 'kafka',
+    ...
+)
+AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;
+```
+
+The `[CREATE OR] REPLACE TABLE` statement is equivalent to first drop the 
table, then create the table and insert the data with the following statement:

Review Comment:
   Thank you for the reminder, in order to avoid the cost of explaining too 
much here, I will put the introduction of RTAS semantics at the very beginning, 
and subsequently we will use the example of REPLACE TABLE AS SELECT



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to