You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: doc/cql3/CQL.textile
+7-4
Original file line number
Diff line number
Diff line change
@@ -414,16 +414,19 @@ bc(syntax)..
414
414
<copy-table-stmt> ::= CREATE ( TABLE | COLUMNFAMILY ) ( IF NOT EXISTS )? <newtablename> LIKE <oldtablename>
415
415
( WITH <option> ( AND <option>)* )?
416
416
417
-
<option> ::= <property>
417
+
<option> ::= <property> | INDEXES
418
418
419
-
p.
419
+
p.
420
420
__Sample:__
421
421
422
422
bc(sample)..
423
423
CREATE TABLE newtb1 LIKE oldtb;
424
424
425
425
CREATE TABLE newtb2 LIKE oldtb WITH compaction = { 'class' : 'LeveledCompactionStrategy' };
426
-
p.
426
+
427
+
CREATE TABLE newtb4 LIKE oldtb WITH INDEXES AND compaction = { 'class' : 'LeveledCompactionStrategy' };
428
+
429
+
p.
427
430
The @COPY TABLE@ statement creates a new table which is a clone of old table. The new table have the same column numbers, column names, column data types, column data mask with the old table. The new table is defined by a "name":#copyNewTableName, and the name of the old table being cloned is defined by a "name":#copyOldTableName . The table options of the new table can be defined by setting "copyoptions":#copyTableOptions. Note that the @CREATE COLUMNFAMILY LIKE@ syntax is supported as an alias for @CREATE TABLE like@ (for historical reasons).
428
431
429
432
Attempting to create an already existing table will return an error unless the @IF NOT EXISTS@ option is used. If it is used, the statement will be a no-op if the table already exists.
@@ -438,7 +441,7 @@ The old table name defines the already existed table.
438
441
439
442
h4(#copyTableOptions). @<copyoptions>@
440
443
441
-
The @COPY TABLE@ statement supports a number of options that controls the configuration of a new table. These options can be specified after the @WITH@ keyword, and all options are the same as those options when creating a table except for id.
444
+
The @COPY TABLE@ statement supports a number of options that controls the configuration of a new table. These options can be specified after the @WITH@ keyword, and all options are the same as those options when creating a table except for id. Besides the options can also be specified with keyword INDEXES which means copy source table's indexes.
// The rules for generating the index names of the target table are:
261
+
// (1) If the source table's index names follow the pattern sourcetablename_columnname_idx_number, the index names are considered to be generated by the system,
262
+
// then we directly replace the name of source table with the name of target table, and increment the number after idx to avoid index name conflicts.
263
+
// (2) Index names that do not follow the above pattern are considered user-defined, so the index names are retained and increment the number after idx to avoid conflicts.
264
+
if (indexMetadata.name.startsWith(sourceTableName + "_" + targetColumn.name + "_idx"))
0 commit comments