Cassandra CQL使用详解

Data Types:

cql_type ::=native_type | collection_type | user_defined_type | tuple_type | custom_type

Native Types:


Counters:

counter type is used to define counter columns. 存储64-bit signed integer 并且支持两种操作 incrementing(增值) and decrementing(减值).

注意计数器的值不能被设置:当counter does not exist until first incremented / decremented,第一次increment / decrement 之前的值是0.

Counters 有几点重要限制:

1)They cannot be used for columns part of the PRIMARY KEY of a table .

2)主键的表的所有列为计数器类型,或者没有一个是计数器类型的.

3)Counters 不支持终止.

4)The delete of counters is supported, but is only guaranteed(担保) to work the first time you delete a counter . 换句话说,你不能重复修改 a counter that you have deleted(if you do , proper behavior is not guaranteed).

5)if a counter update fails unexpectedly(timeout or loss of connection) the client has no way to know if the update has been applied or not , In particular,replaying the update may or may not lead to an over count.


Working with timestamps:

Values of the timestamp type are encode as 64-bit signed integers representing a number of milliseconds since the standard base time known as :January 1 1970

Timestamps can be input in CQL either using their value as an integer ,or using a string that represents as ISO 8601 date. For instance ,all of the values below:

  • 1299038700000
  • '2011-02-0304:05+0000'
  • '2011-02-0304:05:00+0000'
  • '2011-02-0304:05:00.000+0000'
  • '2011-02-03T04:05+0000'
  • '2011-02-03T04:05:00+0000'
  • '2011-02-03T04:05:00.000+0000'

Working with dates:

Values of the datetype are encoded as 32-bit unsigned integers representing a number of days with “the epoch” atthe center of the range (2^31). Epoch is January 1st, 1970

As for timestamp, a date can be input either as aninteger or using a datestring. In the later case, the format should be yyyy-mm-dd (so'2011-02-03' for instance).


Working with times:

Values of the timetype are encoded as 64-bit signed integers representing the number of nanoseconds since midnight.

As for timestamp, a time can be input either as aninteger or using astringrepresenting the time. In the later case, the format should behh:mm:ss[.fffffffff] (where the sub-second precisionis optional and if provided, can be less than the nanosecond). So for instance, the following are valid inputs for atime:

  • '08:12:54'
  • '08:12:54.123'
  • '08:12:54.123456'
  • '08:12:54.123456789'

Collections:

CQL supports 3 kind of collections : Maps   Sets   Lists

Maps:

A map is a (sorted) set of key-value pairs,where keys are unique and the map is sorted by its keys.











  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值