Skip to content

Commit 3fb88e0

Browse files
committed
Add missed documentation for CREATE TABLE LIKE
patch by Maxwell guo; reviewed by Brad Schoening and Michael Semb Wever for CASSANDRA-20491
1 parent df96494 commit 3fb88e0

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
5.1
2+
* Add missed documentation for CREATE TABLE LIKE (CASSANDRA-20401)
23
* Add OCTET_LENGTH constraint (CASSANDRA-20340)
34
* Reduce memory allocations in miscellaneous places along the hot write path (CASSANDRA-20167)
45
* Provide keystore_password_file and truststore_password_file options to read credentials from a file (CASSANDRA-13428)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
create_table_statement::= CREATE TABLE [ IF NOT EXISTS ] new_table_name LIKE old_table_name
2-
[ WITH table_options ]
3-
table_options::= INDEXES | options [ AND table_options ]
2+
[ WITH like_options ]
3+
like_options::= INDEXES | options [ AND like_options ]

doc/modules/cassandra/pages/developing/cql/cql_singlefile.adoc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,55 @@ new columns (see `ALTER TABLE`) is a constant time operation. There is
708708
thus no need to try to anticipate future usage (or to cry when you
709709
haven’t) when creating a table.
710710

711+
[[copyTableStmt]]
712+
=== CREATE TABLE LIKE
713+
714+
_Syntax:_
715+
716+
[source,bnf]
717+
include::cassandra:example$BNF/create_table_like.bnf[]
718+
719+
_Sample:_
720+
721+
[source,sql]
722+
----
723+
include::cassandra:example$CQL/create_table_like.cql[]
724+
----
725+
726+
The `CREATE TABLE LIKE` statement creates a new empty table based on
727+
the definition of an already existing table. By default, the new table
728+
will have the same schema as the existing table.
729+
730+
The statement allows changing the new table's options using the `WITH`
731+
keyword. Additionally, the new table can create indexes with the same
732+
schema as the existing table's indexes if the `INDEXES` keyword is specified.
733+
However, only SAI and legacy secondary indexes are supported. TRIGGER
734+
and MATERIALIZED VIEW are not supported at this time.
735+
736+
Attempting to create a table that already exists will return an error
737+
unless the IF NOT EXISTS option is used. If this option is used, the
738+
statement will have no effect if the table already exists.
739+
740+
[[copyTableStmt]]
741+
==== `<tablename>`
742+
743+
Valid the newly created table names are the same as valid
744+
link:#createTableStmt[table names] (up to 32 characters long
745+
alphanumerical identifiers). If the table name is provided alone, the
746+
table is created within the current keyspace (see `USE`), but if it is
747+
prefixed by an existing keyspace name (see
748+
link:#copyTableStmt[`<tablename>`] grammar), it is created in the specified
749+
keyspace (but does *not* change the current keyspace).
750+
751+
[[createTableLikeOptions]]
752+
==== `<like option>`
753+
754+
The table options specified by `CREATE TABLE LIKE` statement are the same
755+
as the supported link:#createTableOptions[supported `<option>`] in the
756+
`CREATE TABLE` statement. And both are set throught keyword `WITH`.
757+
758+
Indexs will be created together with table if `INDEXES` keyword is used.
759+
711760
[[alterTableStmt]]
712761
==== ALTER TABLE
713762

0 commit comments

Comments
 (0)