【问题标题】:Using timestamp as column name in CQL在 CQL 中使用时间戳作为列名
【发布时间】:2013-09-07 16:57:22
【问题描述】:

我正在使用 CQL 创建一个列族,其中时间戳作为我在 cassandra 中的列名。以前有人试过吗?我查看了 CQL 语法中的 timeuuid 函数。但我不确定如何在 CREATE 或 UPDATE 查询中使用它们中的任何一个来创建带有时间戳的列名。

【问题讨论】:

    标签: timestamp cassandra cql


    【解决方案1】:

    您可以使用now() 函数生成包含当前时间的时间UUID。例如:

    create table timeuuid_test (key timeuuid primary key, value text);
    insert into timeuuid_test (key, value) VALUES (now(), 'hello');
    insert into timeuuid_test (key, value) VALUES (now(), 'hello2');
    select * from timeuuid_test;
    
     key                                  | value
    --------------------------------------+--------
     0ad77930-179b-11e3-8f29-19ac47defd2c |  hello
     0c305270-179b-11e3-8f29-19ac47defd2c | hello2
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      • 2017-01-30
      • 2014-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多