mirror of https://github.com/apache/cassandra
Merge branch cassandra-4.0 into cassandra-4.1
This commit is contained in:
commit
00ad7f2ed9
|
|
@ -18,7 +18,7 @@
|
|||
#
|
||||
-->
|
||||
|
||||
h1. Cassandra Query Language (CQL) v3.4.3
|
||||
h1. Cassandra Query Language (CQL) v3.4.6
|
||||
|
||||
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ h3(#alterKeyspaceStmt). ALTER KEYSPACE
|
|||
__Syntax:__
|
||||
|
||||
bc(syntax)..
|
||||
<create-keyspace-stmt> ::= ALTER KEYSPACE <identifier> WITH <properties>
|
||||
<create-keyspace-stmt> ::= ALTER KEYSPACE (IF EXISTS)? <identifier> WITH <properties>
|
||||
p.
|
||||
__Sample:__
|
||||
|
||||
|
|
@ -225,6 +225,7 @@ ALTER KEYSPACE Excelsior
|
|||
|
||||
p.
|
||||
The @ALTER KEYSPACE@ statement alters the properties of an existing keyspace. The supported @<properties>@ are the same as for the "@CREATE KEYSPACE@":#createKeyspaceStmt statement.
|
||||
If the keyspace does not exist, the statement will return an error, unless @IF EXISTS@ is used in which case the operation is a no-op.
|
||||
|
||||
|
||||
h3(#dropKeyspaceStmt). DROP KEYSPACE
|
||||
|
|
@ -410,12 +411,11 @@ h3(#alterTableStmt). ALTER TABLE
|
|||
__Syntax:__
|
||||
|
||||
bc(syntax)..
|
||||
<alter-table-stmt> ::= ALTER (TABLE | COLUMNFAMILY) <tablename> <instruction>
|
||||
<alter-table-stmt> ::= ALTER (TABLE | COLUMNFAMILY) (IF NOT EXISTS)? <tablename> <instruction>
|
||||
|
||||
<instruction> ::= ADD <identifier> <type>
|
||||
| ADD ( <identifier> <type> ( , <identifier> <type> )* )
|
||||
| DROP <identifier>
|
||||
| DROP ( <identifier> ( , <identifier> )* )
|
||||
<instruction> ::= ADD (IF NOT EXISTS)? ( <identifier> <type> ( , <identifier> <type> )* )
|
||||
| DROP (IF EXISTS)? ( <identifier> ( , <identifier> )* )
|
||||
| RENAME (IF EXISTS)? <identifier> to <identifier> (AND <identifier> to <identifier>)*
|
||||
| DROP COMPACT STORAGE
|
||||
| WITH <option> ( AND <option> )*
|
||||
p.
|
||||
|
|
@ -432,9 +432,12 @@ WITH comment = 'A most excellent and useful column family';
|
|||
p.
|
||||
The @ALTER@ statement is used to manipulate table definitions. It allows for adding new columns, dropping existing ones, or updating the table options. As with table creation, @ALTER COLUMNFAMILY@ is allowed as an alias for @ALTER TABLE@.
|
||||
|
||||
If the table does not exist, the statement will return an error, unless @IF EXISTS@ is used in which case the operation is a no-op.
|
||||
|
||||
The @<tablename>@ is the table name optionally preceded by the keyspace name. The @<instruction>@ defines the alteration to perform:
|
||||
* @ADD@: Adds a new column to the table. The @<identifier>@ for the new column must not conflict with an existing column. Moreover, columns cannot be added to tables defined with the @COMPACT STORAGE@ option.
|
||||
* @DROP@: Removes a column from the table. Dropped columns will immediately become unavailable in the queries and will not be included in compacted sstables in the future. If a column is readded, queries won't return values written before the column was last dropped. It is assumed that timestamps represent actual time, so if this is not your case, you should NOT readd previously dropped columns. Columns can't be dropped from tables defined with the @COMPACT STORAGE@ option.
|
||||
* @ADD@: Adds a new column to the table. The @<identifier>@ for the new column must not conflict with an existing column. Moreover, columns cannot be added to tables defined with the @COMPACT STORAGE@ option. If the new column already exists, the statement will return an error, unless @IF NOT EXISTS@ is used in which case the operation is a no-op.
|
||||
* @DROP@: Removes a column from the table. Dropped columns will immediately become unavailable in the queries and will not be included in compacted sstables in the future. If a column is readded, queries won't return values written before the column was last dropped. It is assumed that timestamps represent actual time, so if this is not your case, you should NOT readd previously dropped columns. Columns can't be dropped from tables defined with the @COMPACT STORAGE@ option. If the dropped column does not already exist, the statement will return an error, unless @IF EXISTS@ is used in which case the operation is a no-op.
|
||||
* @RENAME@ a primary key column of a table. Non primary key columns cannot be renamed. Furthermore, renaming a column to another name which already exists isn't allowed. It's important to keep in mind that renamed columns shouldn't have dependent secondary indexes. If the renamed column does not already exist, the statement will return an error, unless @IF EXISTS@ is used in which case the operation is a no-op.
|
||||
* @DROP COMPACT STORAGE@: Removes Thrift compatibility mode from the table.
|
||||
* @WITH@: Allows to update the options of the table. The "supported @<option>@":#createTableOptions (and syntax) are the same as for the @CREATE TABLE@ statement except that @COMPACT STORAGE@ is not supported. Note that setting any @compaction@ sub-options has the effect of erasing all previous @compaction@ options, so you need to re-specify all the sub-options if you want to keep them. The same note applies to the set of @compression@ sub-options.
|
||||
|
||||
|
|
@ -568,12 +571,12 @@ h3(#alterMVStmt). ALTER MATERIALIZED VIEW
|
|||
|
||||
__Syntax:__
|
||||
|
||||
bc(syntax). <alter-materialized-view-stmt> ::= ALTER MATERIALIZED VIEW <viewname>
|
||||
bc(syntax). <alter-materialized-view-stmt> ::= ALTER MATERIALIZED VIEW (IF EXISTS)? <viewname>
|
||||
WITH <option> ( AND <option> )*
|
||||
|
||||
p.
|
||||
p.
|
||||
The @ALTER MATERIALIZED VIEW@ statement allows options to be update; these options are the same as <a href="#createTableOptions">@CREATE TABLE@'s options</a>.
|
||||
|
||||
If the view does not exist, the statement will return an error, unless @IF EXISTS@ is used in which case the operation is a no-op.
|
||||
|
||||
h3(#dropMVStmt). DROP MATERIALIZED VIEW
|
||||
|
||||
|
|
@ -633,10 +636,10 @@ h3(#alterTypeStmt). ALTER TYPE
|
|||
__Syntax:__
|
||||
|
||||
bc(syntax)..
|
||||
<alter-type-stmt> ::= ALTER TYPE <typename> <instruction>
|
||||
<alter-type-stmt> ::= ALTER TYPE (IF EXISTS)? <typename> <instruction>
|
||||
|
||||
<instruction> ::= ADD <field-name> <type>
|
||||
| RENAME <field-name> TO <field-name> ( AND <field-name> TO <field-name> )*
|
||||
<instruction> ::= ADD (IF NOT EXISTS)? <field-name> <type>
|
||||
| RENAME (IF EXISTS)? <field-name> TO <field-name> ( AND <field-name> TO <field-name> )*
|
||||
p.
|
||||
__Sample:__
|
||||
|
||||
|
|
@ -646,6 +649,7 @@ ALTER TYPE address ADD country text
|
|||
ALTER TYPE address RENAME zip TO zipcode AND street_name TO street
|
||||
p.
|
||||
The @ALTER TYPE@ statement is used to manipulate type definitions. It allows for adding new fields, renaming existing fields, or changing the type of existing fields.
|
||||
If the type does not exist, the statement will return an error, unless @IF EXISTS@ is used in which case the operation is a no-op.
|
||||
|
||||
h3(#dropTypeStmt). DROP TYPE
|
||||
|
||||
|
|
@ -855,7 +859,7 @@ __Syntax:__
|
|||
bc(syntax)..
|
||||
<insertStatement> ::= INSERT INTO <tablename>
|
||||
( ( <name-list> VALUES <value-list> )
|
||||
| ( JSON <string> ))
|
||||
| ( JSON <string> (DEFAULT ( NULL | UNSET ))?))
|
||||
( IF NOT EXISTS )?
|
||||
( USING <option> ( AND <option> )* )?
|
||||
|
||||
|
|
@ -909,7 +913,7 @@ bc(syntax)..
|
|||
| <identifier> '.' <field> <op> <term>
|
||||
| <identifier> '.' <field> IN <in-values>
|
||||
|
||||
<op> ::= '<' | '<=' | '=' | '!=' | '>=' | '>'
|
||||
<op> ::= '<' | '<=' | '=' | '!=' | '>=' | '>' | CONTAINS ( KEY )?
|
||||
<in-values> ::= (<variable> | '(' ( <term> ( ',' <term> )* )? ')')
|
||||
|
||||
<where-clause> ::= <relation> ( AND <relation> )*
|
||||
|
|
@ -953,7 +957,7 @@ h4(#updateOptions). @<options>@
|
|||
|
||||
The @UPDATE@ and @INSERT@ statements support the following options:
|
||||
* @TIMESTAMP@: sets the timestamp for the operation. If not specified, the coordinator will use the current time (in microseconds) at the start of statement execution as the timestamp. This is usually a suitable default.
|
||||
* @TTL@: specifies an optional Time To Live (in seconds) for the inserted values. If set, the inserted values are automatically removed from the database after the specified time. Note that the TTL concerns the inserted values, not the columns themselves. This means that any subsequent update of the column will also reset the TTL (to whatever TTL is specified in that update). By default, values never expire. A TTL of 0 is equivalent to no TTL. If the table has a default_time_to_live, a TTL of 0 will remove the TTL for the inserted or updated values.
|
||||
* @TTL@: specifies an optional Time To Live (in seconds) for the inserted values. If set, the inserted values are automatically removed from the database after the specified time. Note that the TTL concerns the inserted values, not the columns themselves. This means that any subsequent update of the column will also reset the TTL (to whatever TTL is specified in that update). By default, values never expire. A TTL of 0 is equivalent to no TTL. If the table has a default_time_to_live, a TTL of 0 will remove the TTL for the inserted or updated values. A TTL of @null@ is equivalent to inserting with a TTL of 0.
|
||||
|
||||
|
||||
h3(#deleteStmt). DELETE
|
||||
|
|
@ -980,7 +984,7 @@ bc(syntax)..
|
|||
| '(' <identifier> (',' <identifier>)* ')' IN '(' ( <term-tuple> ( ',' <term-tuple>)* )? ')'
|
||||
| '(' <identifier> (',' <identifier>)* ')' IN <variable>
|
||||
|
||||
<op> ::= '=' | '<' | '>' | '<=' | '>='
|
||||
<op> ::= '=' | '<' | '>' | '<=' | '>=' | CONTAINS ( KEY )?
|
||||
<in-values> ::= (<variable> | '(' ( <term> ( ',' <term> )* )? ')')
|
||||
|
||||
<condition> ::= <identifier> (<op> | '!=') <term>
|
||||
|
|
@ -1258,7 +1262,7 @@ __Syntax:__
|
|||
bc(syntax)..
|
||||
<create-role-stmt> ::= CREATE ROLE ( IF NOT EXISTS )? <identifier> ( WITH <option> ( AND <option> )* )?
|
||||
|
||||
<option> ::= PASSWORD = <string>
|
||||
<option> ::= ("HASHED")? PASSWORD = <string>
|
||||
| LOGIN = <boolean>
|
||||
| SUPERUSER = <boolean>
|
||||
| OPTIONS = <map_literal>
|
||||
|
|
@ -1300,7 +1304,7 @@ h3(#alterRoleStmt). ALTER ROLE
|
|||
__Syntax:__
|
||||
|
||||
bc(syntax)..
|
||||
<alter-role-stmt> ::= ALTER ROLE <identifier> ( WITH <option> ( AND <option> )* )?
|
||||
<alter-role-stmt> ::= ALTER ROLE (IF EXISTS)? <identifier> ( WITH <option> ( AND <option> )* )?
|
||||
|
||||
<option> ::= PASSWORD = <string>
|
||||
| LOGIN = <boolean>
|
||||
|
|
@ -1319,7 +1323,7 @@ Conditions on executing @ALTER ROLE@ statements:
|
|||
* A client cannot alter the @SUPERUSER@ status of any role it currently holds
|
||||
* A client can only modify certain properties of the role with which it identified at login (e.g. @PASSWORD@)
|
||||
* To modify properties of a role, the client must be granted @ALTER@ "permission":#permissions on that role
|
||||
|
||||
If the role does not exist, the statement will return an error, unless @IF EXISTS@ is used in which case the operation is a no-op.
|
||||
|
||||
h3(#dropRoleStmt). DROP ROLE
|
||||
|
||||
|
|
@ -1411,7 +1415,7 @@ Prior to the introduction of roles in Cassandra 2.2, authentication and authoriz
|
|||
__Syntax:__
|
||||
|
||||
bc(syntax)..
|
||||
<create-user-statement> ::= CREATE USER ( IF NOT EXISTS )? <identifier> ( WITH PASSWORD <string> )? (<option>)?
|
||||
<create-user-statement> ::= CREATE USER ( IF NOT EXISTS )? <identifier> ( WITH ("HASHED")? PASSWORD <string> )? (<option>)?
|
||||
|
||||
<option> ::= SUPERUSER
|
||||
| NOSUPERUSER
|
||||
|
|
@ -1447,11 +1451,12 @@ h3(#alterUserStmt). ALTER USER
|
|||
__Syntax:__
|
||||
|
||||
bc(syntax)..
|
||||
<alter-user-statement> ::= ALTER USER <identifier> ( WITH PASSWORD <string> )? ( <option> )?
|
||||
<alter-user-statement> ::= ALTER USER (IF EXISTS)? <identifier> ( WITH PASSWORD <string> )? ( <option> )?
|
||||
|
||||
<option> ::= SUPERUSER
|
||||
| NOSUPERUSER
|
||||
p.
|
||||
If the user does not exist, the statement will return an error, unless @IF EXISTS@ is used in which case the operation is a no-op.
|
||||
|
||||
bc(sample).
|
||||
ALTER USER alice WITH PASSWORD 'PASSWORD_A';
|
||||
|
|
@ -1581,12 +1586,13 @@ h3(#grantPermissionsStmt). GRANT PERMISSION
|
|||
__Syntax:__
|
||||
|
||||
bc(syntax)..
|
||||
<grant-permission-stmt> ::= GRANT ( ALL ( PERMISSIONS )? | <permission> ( PERMISSION )? ) ON <resource> TO <identifier>
|
||||
<grant-permission-stmt> ::= GRANT ( ALL ( PERMISSIONS )? | <permission> ( PERMISSION )? (, PERMISSION)* ) ON <resource> TO <identifier>
|
||||
|
||||
<permission> ::= CREATE | ALTER | DROP | SELECT | MODIFY | AUTHORIZE | DESRIBE | EXECUTE
|
||||
|
||||
<resource> ::= ALL KEYSPACES
|
||||
| KEYSPACE <identifier>
|
||||
| ALL TABLES IN KEYSPACE <identifier>
|
||||
| ( TABLE )? <tablename>
|
||||
| ALL ROLES
|
||||
| ROLE <identifier>
|
||||
|
|
@ -1637,12 +1643,13 @@ h3(#revokePermissionsStmt). REVOKE PERMISSION
|
|||
__Syntax:__
|
||||
|
||||
bc(syntax)..
|
||||
<revoke-permission-stmt> ::= REVOKE ( ALL ( PERMISSIONS )? | <permission> ( PERMISSION )? ) ON <resource> FROM <identifier>
|
||||
<revoke-permission-stmt> ::= REVOKE ( ALL ( PERMISSIONS )? | <permission> ( PERMISSION )? (, PERMISSION)* ) ON <resource> FROM <identifier>
|
||||
|
||||
<permission> ::= CREATE | ALTER | DROP | SELECT | MODIFY | AUTHORIZE | DESRIBE | EXECUTE
|
||||
|
||||
<resource> ::= ALL KEYSPACES
|
||||
| KEYSPACE <identifier>
|
||||
| ALL TABLES IN KEYSPACE <identifier>
|
||||
| ( TABLE )? <tablename>
|
||||
| ALL ROLES
|
||||
| ROLE <identifier>
|
||||
|
|
@ -1650,7 +1657,7 @@ bc(syntax)..
|
|||
| FUNCTION <functionname>
|
||||
| ALL MBEANS
|
||||
| ( MBEAN | MBEANS ) <objectName>
|
||||
p.
|
||||
p.
|
||||
|
||||
__Sample:__
|
||||
|
||||
|
|
@ -1673,6 +1680,7 @@ bc(syntax)..
|
|||
|
||||
<resource> ::= ALL KEYSPACES
|
||||
| KEYSPACE <identifier>
|
||||
| ALL TABLES IN KEYSPACE <identifier>
|
||||
| ( TABLE )? <tablename>
|
||||
| ALL ROLES
|
||||
| ROLE <identifier>
|
||||
|
|
@ -1680,7 +1688,7 @@ bc(syntax)..
|
|||
| FUNCTION <functionname>
|
||||
| ALL MBEANS
|
||||
| ( MBEAN | MBEANS ) <objectName>
|
||||
p.
|
||||
p.
|
||||
|
||||
__Sample:__
|
||||
|
||||
|
|
@ -1719,6 +1727,7 @@ bc(syntax)..
|
|||
| date
|
||||
| decimal
|
||||
| double
|
||||
| duration
|
||||
| float
|
||||
| inet
|
||||
| int
|
||||
|
|
@ -1749,6 +1758,7 @@ p. The following table gives additional informations on the native data types, a
|
|||
|@date@ | integers, strings |A date (with no corresponding time value). See "Working with dates":#usingdates below for more information.|
|
||||
|@decimal@ | integers, floats |Variable-precision decimal|
|
||||
|@double@ | integers |64-bit IEEE-754 floating point|
|
||||
|@duration@ | duration |A duration with nanosecond precision. See "Working with durations":#usingdurations below for details.|
|
||||
|@float@ | integers, floats |32-bit IEEE-754 floating point|
|
||||
|@inet@ | strings |An IP address. It can be either 4 bytes long (IPv4) or 16 bytes long (IPv6). There is no @inet@ constant, IP address should be inputed as strings|
|
||||
|@int@ | integers |32-bit signed int|
|
||||
|
|
@ -1822,6 +1832,44 @@ They can also be input as string literals in any of the following formats:
|
|||
* @08:12:54.123456@
|
||||
* @08:12:54.123456789@
|
||||
|
||||
h3(#usingdurations). Working with durations
|
||||
|
||||
Values of the @duration@ type are encoded as 3 signed integers of variable lengths. The first integer represents the
|
||||
number of months, the second the number of days and the third the number of nanoseconds. This is due to the fact that
|
||||
the number of days in a month can change, and a day can have 23 or 25 hours depending on the daylight saving.
|
||||
|
||||
A duration can be input as:
|
||||
|
||||
* (quantity unit)+ like @12h30m@ where the unit can be:
|
||||
** @y@: years (12 months)
|
||||
** @mo@: months (1 month)
|
||||
** @w@: weeks (7 days)
|
||||
** @d@: days (1 day)
|
||||
** @h@: hours (3,600,000,000,000 nanoseconds)
|
||||
** @m@: minutes (60,000,000,000 nanoseconds)
|
||||
** @s@: seconds (1,000,000,000 nanoseconds)
|
||||
** @ms@: milliseconds (1,000,000 nanoseconds)
|
||||
** @us@ or @µs@ : microseconds (1000 nanoseconds)
|
||||
** @ns@: nanoseconds (1 nanosecond)
|
||||
* ISO 8601 format: @P[n]Y[n]M[n]DT[n]H[n]M[n]S@ or @P[n]W@
|
||||
* ISO 8601 alternative format: @P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]@
|
||||
|
||||
For example:
|
||||
|
||||
bc(sample).
|
||||
INSERT INTO RiderResults (rider, race, result) VALUES ('Christopher Froome', 'Tour de France', 89h4m48s);
|
||||
INSERT INTO RiderResults (rider, race, result) VALUES ('BARDET Romain', 'Tour de France', PT89H8M53S);
|
||||
INSERT INTO RiderResults (rider, race, result) VALUES ('QUINTANA Nairo', 'Tour de France', P0000-00-00T89:09:09);
|
||||
|
||||
h4. duration-limitation:
|
||||
|
||||
Duration columns cannot be used in a table's @PRIMARY KEY@. This limitation is due to the fact that
|
||||
durations cannot be ordered. It is effectively not possible to know if @1mo@ is greater than @29d@ without a date
|
||||
context.
|
||||
|
||||
A @1d@ duration is not equals to a @24h@ one as the duration type has been created to be able to support daylight
|
||||
saving.
|
||||
|
||||
|
||||
h3(#counters). Counters
|
||||
|
||||
|
|
@ -1945,6 +1993,47 @@ UPDATE plays SET scores = scores - [ 12, 21 ] WHERE id = '123-afde'; // removes
|
|||
|
||||
As with "maps":#map, TTLs if used only apply to the newly inserted/updated _values_.
|
||||
|
||||
h2(#arithmeticOperators). Arithmetic Operators
|
||||
|
||||
h3(#numberArithmetic). Number Arithmetic
|
||||
|
||||
CQL supports the following operators:
|
||||
|
||||
|_. Operator |_. Description |
|
||||
| @-@ (unary) | Negates operand |
|
||||
| @+@ | Addition |
|
||||
| @-@ | Substraction |
|
||||
| @*@ | Multiplication |
|
||||
| @/@ | Division |
|
||||
| @%@ | Returns the remainder of a division |
|
||||
|
||||
Arithmetic operations are only supported on numeric types or counters.
|
||||
|
||||
The return type of the operation will be based on the operand types:
|
||||
|
||||
|
||||
|_. left/right |_. @tinyint@ |_. @smallint@ |_. @int@ |_. @bigint@ |_. @counter@ |_. @float@ |_. @double@ |_. @varint@ |_. @decimal@ |
|
||||
| **@tinyint@** | @tinyint@ | @smallint@ | @int@ | @bigint@ | @bigint@ | @float@ | @double@ | @varint@ | @decimal@ |
|
||||
| **@smallint@** | @smallint@ | @smallint@ | @int@ | @bigint@ | @bigint@ | @float@ | @double@ | @varint@ | @decimal@ |
|
||||
| **@int@** | @int@ | @int@ | @int@ | @bigint@ | @bigint@ | @float@ | @double@ | @varint@ | @decimal@ |
|
||||
| **@bigint@** | @bigint@ | @bigint@ | @bigint@ | @bigint@ | @bigint@ | @double@ | @double@ | @varint@ | @decimal@ |
|
||||
| **@counter@** | @bigint@ | @bigint@ | @bigint@ | @bigint@ | @bigint@ | @double@ | @double@ | @varint@ | @decimal@ |
|
||||
| **@float@** | @float@ | @float@ | @float@ | @double@ | @double@ | @float@ | @double@ | @decimal@ | @decimal@ |
|
||||
| **@double@** | @double@ | @double@ | @double@ | @double@ | @double@ | @double@ | @double@ | @decimal@ | @decimal@ |
|
||||
| **@varint@** | @varint@ | @varint@ | @varint@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ |
|
||||
| **@decimal@** | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ |
|
||||
|
||||
|
||||
@*@, @/@ and @%@ operators have a higher precedence level than @+@ and @-@ operator. By consequence, they will be evaluated before. If two operator in an expression have the same precedence level, they will be evaluated left to right based on their position in the expression.
|
||||
|
||||
h3(#datetimeArithmetic). Datetime Arithmetic
|
||||
|
||||
A @duration@ can be added (+) or substracted (-) from a @timestamp@ or a @date@ to create a new @timestamp@ or @date@. So for instance:
|
||||
|
||||
bc(sample).
|
||||
SELECT * FROM myTable WHERE t = '2017-01-01' - 2d
|
||||
|
||||
will select all the records with a value of @t@ which is in the last 2 days of 2016.
|
||||
|
||||
h2(#functions). Functions
|
||||
|
||||
|
|
@ -1957,22 +2046,22 @@ The @cast@ function can be used to convert one native datatype to another.
|
|||
The following table describes the conversions supported by the @cast@ function. Cassandra will silently ignore any cast converting a datatype into its own datatype.
|
||||
|
||||
|_. from |_. to |
|
||||
|@ascii@ |@text@, @varchar@ |
|
||||
|@ascii@ |@text@, @varchar@ |
|
||||
|@bigint@ |@tinyint@, @smallint@, @int@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@boolean@ |@text@, @varchar@ |
|
||||
|@counter@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@date@ |@timestamp@ |
|
||||
|@date@ |@timestamp@ |
|
||||
|@decimal@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @double@, @varint@, @text@, @varchar@ |
|
||||
|@double@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@float@ |@tinyint@, @smallint@, @int@, @bigint@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@inet@ |@text@, @varchar@ |
|
||||
|@int@ |@tinyint@, @smallint@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@float@ |@tinyint@, @smallint@, @int@, @bigint@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@inet@ |@text@, @varchar@ |
|
||||
|@int@ |@tinyint@, @smallint@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@smallint@ |@tinyint@, @int@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@time@ |@text@, @varchar@ |
|
||||
|@time@ |@text@, @varchar@ |
|
||||
|@timestamp@|@date@, @text@, @varchar@ |
|
||||
|@timeuuid@ |@timestamp@, @date@, @text@, @varchar@ |
|
||||
|@tinyint@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|
||||
|@uuid@ |@text@, @varchar@ |
|
||||
|@uuid@ |@text@, @varchar@ |
|
||||
|@varint@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @double@, @decimal@, @text@, @varchar@ |
|
||||
|
||||
|
||||
|
|
@ -2016,6 +2105,8 @@ SELECT * FROM myTable WHERE t = now()
|
|||
|
||||
|
||||
will never return any result by design, since the value returned by @now()@ is guaranteed to be unique.
|
||||
@currentTimeUUID@ is an alias of @now@.
|
||||
|
||||
|
||||
h4. @minTimeuuid@ and @maxTimeuuid@
|
||||
|
||||
|
|
@ -2030,7 +2121,25 @@ will select all rows where the @timeuuid@ column @t@ is strictly older than '201
|
|||
|
||||
_Warning_: We called the values generated by @minTimeuuid@ and @maxTimeuuid@ _fake_ UUID because they do no respect the Time-Based UUID generation process specified by the "RFC 4122":http://www.ietf.org/rfc/rfc4122.txt. In particular, the value returned by these 2 methods will not be unique. This means you should only use those methods for querying (as in the example above). Inserting the result of those methods is almost certainly _a bad idea_.
|
||||
|
||||
h3(#timeFun). Time conversion functions
|
||||
|
||||
h3(#datetimeFun). Datetime functions
|
||||
|
||||
h4(#curentDateTime). Retrieving the current date/time
|
||||
|
||||
The following functions can be used to retrieve the date/time at the time where the function is invoked:
|
||||
|
||||
|_. function name |_. output type |
|
||||
| @currentTimestamp@ | @timestamp@ |
|
||||
| @currentDate@ | @date@ |
|
||||
| @currentTime@ | @time@ |
|
||||
| @currentTimeUUID@ | @timeUUID@ |
|
||||
|
||||
For example the last 2 days of data can be retrieved using:
|
||||
|
||||
bc(sample).
|
||||
SELECT * FROM myTable WHERE date >= currentDate() - 2d
|
||||
|
||||
h4(#timeFun). Time conversion functions
|
||||
|
||||
A number of functions are provided to "convert" a @timeuuid@, a @timestamp@ or a @date@ into another @native@ type.
|
||||
|
||||
|
|
@ -2045,6 +2154,16 @@ A number of functions are provided to "convert" a @timeuuid@, a @timestamp@ or a
|
|||
|@dateOf@ |@timeuuid@ |Similar to @toTimestamp(timeuuid)@ (DEPRECATED)|
|
||||
|@unixTimestampOf@ |@timeuuid@ |Similar to @toUnixTimestamp(timeuuid)@ (DEPRECATED)|
|
||||
|
||||
h4(#floorFun). Floor function
|
||||
|
||||
Rounds date and time to the nearest value.
|
||||
|
||||
|_. type |_. function |_. |
|
||||
|@timestamp@ | floor(timestamp, duration [, start_timestamp]) | If the start_timestamp is not used, then the start timestamp is January 1, 1970 00:00:00.000 GMT |
|
||||
|@timeuuid@ | floor(timeuuid, duration [, start_timestamp]) | If the start_timestamp is not used, then the start timestamp is January 1, 1970 00:00:00.000 GMT |
|
||||
|@date@ | floor(date, duration [, start_date]) | If the start_date is not used, then the start date is January 1, 1970 GMT |
|
||||
|@time@ | floor(time, duration [, start_time]) | ==If the start_time is not used, then the start time is 00:00:00[000000000]== |
|
||||
|
||||
h3(#blobFun). Blob conversion functions
|
||||
|
||||
A number of functions are provided to "convert" the native types into binary data (@blob@). For every @<native-type>@ @type@ supported by CQL3 (a notable exceptions is @blob@, for obvious reasons), the function @typeAsBlob@ takes a argument of type @type@ and return it as a @blob@. Conversely, the function @blobAsType@ takes a 64-bit @blob@ argument and convert it to a @bigint@ value. And so for instance, @bigintAsBlob(3)@ is @0x0000000000000003@ and @blobAsBigint(0x0000000000000003)@ is @3@.
|
||||
|
|
@ -2250,7 +2369,7 @@ With @INSERT@ statements, the new @JSON@ keyword can be used to enable inserting
|
|||
bc(sample).
|
||||
INSERT INTO mytable JSON '{"\"myKey\"": 0, "value": 0}'
|
||||
|
||||
Any columns which are ommitted from the @JSON@ map will be defaulted to a @NULL@ value (which will result in a tombstone being created).
|
||||
By default (or if @DEFAULT NULL@ is explicitly used), a column omitted from the @JSON@ map will be set to @NULL@, meaning that any pre-existing value for that column will be removed (resulting in a tombstone being created). Alternatively, if the @DEFAULT UNSET@ directive is used after the value, omitted column values will be left unset, meaning that pre-existing values for those column will be preserved.
|
||||
|
||||
h3(#jsonEncoding). JSON Encoding of Cassandra Data Types
|
||||
|
||||
|
|
@ -2451,9 +2570,34 @@ h2(#changes). Changes
|
|||
|
||||
The following describes the changes in each version of CQL.
|
||||
|
||||
h3. 3.4.6
|
||||
|
||||
* Add support for @IF EXISTS@ and @IF NOT EXISTS@ in @ALTER@ statements (see "CASSANDRA-16916":https://issues.apache.org/jira/browse/CASSANDRA-16916).
|
||||
* Allow @GRANT/REVOKE@ multiple permissions in a single statement (see "CASSANDRA-17030":https://issues.apache.org/jira/browse/CASSANDRA-17030).
|
||||
* Pre hashed passwords in CQL (see "CASSANDRA-17334":https://issues.apache.org/jira/browse/CASSANDRA-17334).
|
||||
* Add support for type casting in @WHERE@ clause components and in the values of @INSERT/UPDATE@ statements (see "CASSANDRA-14337":https://issues.apache.org/jira/browse/CASSANDRA-14337).
|
||||
* Add support for @CONTAINS@ and @CONTAINS KEY@ in conditional @UPDATE@ and @DELETE@ statement (see "CASSANDRA-10537":https://issues.apache.org/jira/browse/CASSANDRA-10537).
|
||||
* Allow to grant permission for all tables in a keyspace (see "CASSANDRA-17027":https://issues.apache.org/jira/browse/CASSANDRA-17027).
|
||||
* Allow to use pure monotonic functions on the last attribute of the @GROUP BY@ clause (see "CASSANDRA-11871":https://issues.apache.org/jira/browse/CASSANDRA-11871).
|
||||
* Add floor function to allow grouping by time range (see "CASSANDRA-11871":https://issues.apache.org/jira/browse/CASSANDRA-11871).
|
||||
|
||||
h3. 3.4.5
|
||||
|
||||
* Adds support for arithmetic operators. See "Number Arithmetic":#numberArithmetic (see "CASSANDRA-11935":https://issues.apache.org/jira/browse/CASSANDRA-11935).
|
||||
* Adds support for + and - operations on dates. See "Datetime Arithmetic":#datetimeArithmetic (see "CASSANDRA-11936":https://issues.apache.org/jira/browse/CASSANDRA-11936).
|
||||
* Adds @currentTimestamp@, @currentDate@, @currentTime@ and @currentTimeUUID@ functions (see "CASSANDRA-13132":https://issues.apache.org/jira/browse/CASSANDRA-13132).
|
||||
|
||||
h3. 3.4.4
|
||||
|
||||
* @ALTER TABLE ALTER@ has been removed; a column’s type may not be changed after creation (see "CASSANDRA-12443":https://issues.apache.org/jira/browse/CASSANDRA-12443).
|
||||
* @ALTER TYPE ALTER@ has been removed; a field’s type may not be changed after creation (see "CASSANDRA-12443":https://issues.apache.org/jira/browse/CASSANDRA-12443).
|
||||
|
||||
h3. 3.4.3
|
||||
|
||||
* Adds a new @duration@ data type See "Data Types":#types (see "CASSANDRA-11873":https://issues.apache.org/jira/browse/CASSANDRA-11873).
|
||||
* Support for @GROUP BY@. See "@<group-by>@":#selectGroupBy (see "CASSANDRA-10707":https://issues.apache.org/jira/browse/CASSANDRA-10707).
|
||||
* Adds a @DEFAULT UNSET@ option for @INSERT JSON@ to ignore omitted columns (see "CASSANDRA-11424":https://issues.apache.org/jira/browse/CASSANDRA-11424).
|
||||
* Allows @null@ as a legal value for TTL on insert and update. It will be treated as equivalent to inserting a 0 (see "CASSANDRA-12216":https://issues.apache.org/jira/browse/CASSANDRA-12216).
|
||||
|
||||
h3. 3.4.2
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue