Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更新Cassandra表中的行是否也会更改写入时间?_Cassandra - Fatal编程技术网

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

更新Cassandra表中的行是否也会更改写入时间?,cassandra,Cassandra,我在卡桑德拉有一张桌子,它一直在更新。 我想知道,行/值的写入时间是否随着行中数据的每次更新而更新,或者当我第一次写入表时,是否只给出了一个从未更改的写入时间(时间戳)。 感谢所有能够回答的人:)由于数据是在每次更新时写入的,因此写入时间也会随着每次更新而更新 此外,写入时间是针对列的,WRITETIME函数还获取该列以检索时间戳 请参阅文档以下示例显示时间戳仅在更新的列上更改: cqlsh:keyspace1> create table keyspace1.testwrites (id

我在卡桑德拉有一张桌子,它一直在更新。 我想知道,行/值的写入时间是否随着行中数据的每次更新而更新,或者当我第一次写入表时,是否只给出了一个从未更改的写入时间(时间戳)。
感谢所有能够回答的人:)

由于数据是在每次更新时写入的,因此写入时间也会随着每次更新而更新

此外,写入时间是针对列的,WRITETIME函数还获取该列以检索时间戳


请参阅文档

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

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

它是更新整行还是只更新我更新数据的列?@Ethas96只更新列,WRITETIME还获取列以检索时间戳。请参阅此处的文档:@ethans96您介意接受答案并投票吗;)