This is an automated email from the ASF dual-hosted git repository.

maxwellguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 3fb88e0f9d Add missed documentation for CREATE TABLE LIKE
3fb88e0f9d is described below

commit 3fb88e0f9d5a41d30e6d9116b972d28d296a35ad
Author: Maxwell Guo <[email protected]>
AuthorDate: Thu Mar 6 15:22:19 2025 +0800

    Add missed documentation for CREATE TABLE LIKE
    
    patch by Maxwell guo; reviewed by Brad Schoening and Michael Semb Wever for 
CASSANDRA-20491
---
 CHANGES.txt                                        |  1 +
 .../cassandra/examples/BNF/create_table_like.bnf   |  4 +-
 .../pages/developing/cql/cql_singlefile.adoc       | 49 ++++++++++++++++++++++
 3 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 6b4bc0d7c1..d326cc95c8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 5.1
+ * Add missed documentation for CREATE TABLE LIKE (CASSANDRA-20401)
  * Add OCTET_LENGTH constraint (CASSANDRA-20340)
  * Reduce memory allocations in miscellaneous places along the hot write path 
(CASSANDRA-20167)
  * Provide keystore_password_file and truststore_password_file options to read 
credentials from a file (CASSANDRA-13428)
diff --git a/doc/modules/cassandra/examples/BNF/create_table_like.bnf 
b/doc/modules/cassandra/examples/BNF/create_table_like.bnf
index ebbd9b4658..2a8914c751 100644
--- a/doc/modules/cassandra/examples/BNF/create_table_like.bnf
+++ b/doc/modules/cassandra/examples/BNF/create_table_like.bnf
@@ -1,3 +1,3 @@
 create_table_statement::= CREATE TABLE [ IF NOT EXISTS ] new_table_name LIKE 
old_table_name
-        [ WITH table_options ]
-table_options::= INDEXES | options [ AND table_options ]
\ No newline at end of file
+        [ WITH like_options ]
+like_options::= INDEXES | options [ AND like_options ]
\ No newline at end of file
diff --git a/doc/modules/cassandra/pages/developing/cql/cql_singlefile.adoc 
b/doc/modules/cassandra/pages/developing/cql/cql_singlefile.adoc
index 5b39524b38..f2bf215906 100644
--- a/doc/modules/cassandra/pages/developing/cql/cql_singlefile.adoc
+++ b/doc/modules/cassandra/pages/developing/cql/cql_singlefile.adoc
@@ -708,6 +708,55 @@ new columns (see `ALTER TABLE`) is a constant time 
operation. There is
 thus no need to try to anticipate future usage (or to cry when you
 haven’t) when creating a table.
 
+[[copyTableStmt]]
+=== CREATE TABLE LIKE
+
+_Syntax:_
+
+[source,bnf]
+include::cassandra:example$BNF/create_table_like.bnf[]
+
+_Sample:_
+
+[source,sql]
+----
+include::cassandra:example$CQL/create_table_like.cql[]
+----
+
+The `CREATE TABLE LIKE` statement creates a new empty table based on
+the definition of an already existing table. By default, the new table
+will have the same schema as the existing table.
+
+The statement allows changing the new table's options using the `WITH`
+keyword. Additionally, the new table can create indexes with the same
+schema as the existing table's indexes if the `INDEXES` keyword is specified.
+However, only SAI and legacy secondary indexes are supported. TRIGGER
+and MATERIALIZED VIEW are not supported at this time.
+
+Attempting to create a table that already exists will return an error
+unless the IF NOT EXISTS option is used. If this option is used, the
+statement will have no effect if the table already exists.
+
+[[copyTableStmt]]
+==== `<tablename>`
+
+Valid the newly created table names are the same as valid
+link:#createTableStmt[table names] (up to 32 characters long
+alphanumerical identifiers). If the table name is provided alone, the
+table is created within the current keyspace (see `USE`), but if it is
+prefixed by an existing keyspace name (see
+link:#copyTableStmt[`<tablename>`] grammar), it is created in the specified
+keyspace (but does *not* change the current keyspace).
+
+[[createTableLikeOptions]]
+==== `<like option>`
+
+The table options specified by `CREATE TABLE LIKE` statement are the same
+as the supported link:#createTableOptions[supported `<option>`] in the
+`CREATE TABLE` statement. And both are set throught keyword `WITH`.
+
+Indexs will be created together with table if `INDEXES` keyword is used.
+
 [[alterTableStmt]]
 ==== ALTER TABLE
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to