【问题标题】:Can I define variables in CQL?我可以在 CQL 中定义变量吗?
【发布时间】:2015-01-03 09:51:34
【问题描述】:

样本:

create table test1(test1Code timeuuid, primary key(test1Code));
create table test2(test2Code timeuuid, primary key(test2Code));

insert into test1(test1Code) values (now());
insert into test2(test2Code) values (now());

这两个表的 timeuuid 值不同。

我希望两个表都插入相同的 now() 值;

我可以将值存储在变量中并在我的语句中使用它吗?

或者我需要使用不同的方法。

【问题讨论】:

    标签: cql datastax


    【解决方案1】:

    在应用层执行业务逻辑

    没有办法在 CQL 中定义/存储变量。在使用 datastax drivers 之一写入 Cassandra 之前,应在应用层处理此步骤。

    你只是在测试吗?

    如果您正在寻找一种快速而肮脏的方法来执行此操作,您可以将 bash 中的 cql 命令生成到一个文件中并运行:

    cqlsh -f <path to file>.cql
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-27
      • 2011-10-08
      • 1970-01-01
      • 2018-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-03
      相关资源
      最近更新 更多