cassandra - 更新 Cassandra 表中的行是否也会改变写入时间?

标签 cassandra

我在 Cassandra 中有一张表,它一直在更新。 我想知道,行/值的写入时间是否随着行中数据的每次更新而更新,或者当我第一次写入永远不会改变的表时,是否只有一个写入时间(时间戳)。 感谢任何能回答的人:)

最佳答案

以下示例显示时间戳仅在更新的列上更改:

cqlsh:keyspace1> create table keyspace1.testwrites (id int primary key, firstname text, lastname text);
cqlsh:keyspace1> insert into testwrites(id, firstname, lastname) values (1, 'Valerie', 'Rodriguez');
cqlsh:keyspace1> select id, firstname, writetime(firstname), lastname, writetime(lastname) from testwrites;

 id | firstname | writetime(firstname) | lastname  | writetime(lastname)
----+-----------+----------------------+-----------+---------------------
  1 |   Valerie |     1561471068014970 | Rodriguez |    1561471068014970

(1 rows)
cqlsh:keyspace1> insert into testwrites(id, firstname, lastname) values (2, 'Valerie', 'Smith');
cqlsh:keyspace1> select id, firstname, writetime(firstname), lastname, writetime(lastname) from testwrites;

 id | firstname | writetime(firstname) | lastname  | writetime(lastname)
----+-----------+----------------------+-----------+---------------------
  1 |   Valerie |     1561471068014970 | Rodriguez |    1561471068014970
  2 |   Valerie |     1561471078606684 |     Smith |    1561471078606684

(2 rows)
cqlsh:keyspace1> insert into testwrites(id, firstname, lastname) values (2, 'Valerie', 'Jones');
cqlsh:keyspace1> select id, firstname, writetime(firstname), lastname, writetime(lastname) from testwrites;

 id | firstname | writetime(firstname) | lastname  | writetime(lastname)
----+-----------+----------------------+-----------+---------------------
  1 |   Valerie |     1561471068014970 | Rodriguez |    1561471068014970
  2 |   Valerie |     1561471097668583 |     Jones |    1561471097668583

(2 rows)
cqlsh:keyspace1> insert into testwrites(id, firstname, lastname) values (3, 'Valerie', 'Garcia');
cqlsh:keyspace1> select id, firstname, writetime(firstname), lastname, writetime(lastname) from testwrites;

 id | firstname | writetime(firstname) | lastname  | writetime(lastname)
----+-----------+----------------------+-----------+---------------------
  1 |   Valerie |     1561471068014970 | Rodriguez |    1561471068014970
  2 |   Valerie |     1561471097668583 |     Jones |    1561471097668583
  3 |   Valerie |     1561471114925083 |    Garcia |    1561471114925083

(3 rows)
cqlsh:keyspace1> update testwrites set firstname='Alex' where id=1;
cqlsh:keyspace1> select id, firstname, writetime(firstname), lastname, writetime(lastname) from testwrites;

 id | firstname | writetime(firstname) | lastname  | writetime(lastname)
----+-----------+----------------------+-----------+---------------------
  1 |      Alex |     1561471131764488 | Rodriguez |    1561471068014970
  2 |   Valerie |     1561471097668583 |     Jones |    1561471097668583
  3 |   Valerie |     1561471114925083 |    Garcia |    1561471114925083

关于cassandra - 更新 Cassandra 表中的行是否也会改变写入时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56749270/

相关文章:

cassandra - "PER PARTITION LIMIT"在cassandra的cql查询中是什么意思?

apache-spark - 如何在 Kubernetes 中对外公开 StatefulSet cassandra 集群的无外设服务

cassandra - Cassandra 中的 TokenAware 政策

c# - Cassandra C# insert 似乎正在删除先前的数据?

java - 关于 lambda 的 Cassandra 编译问题

mysql - 加载大量数据(10000 个信号 - 时间序列)

java - Cassandra 选择查询中替换 Null 函数

java - Apache Cassandra 启动失败 : FSWriteError (. ..) 不允许操作

hadoop - 如何使用 UPDATE 使用 CQL 插入到只有主键的表中?

cassandra - STCS : how I can improve compaction performance?