插入自动递增的行

Insert row with auto increment

我创造了这个table

CREATE TABLE table_test(
   id uuid PRIMARY KEY,
   varchar,
  description varchar
);

而且我期望因为 id 是 uuid,所以它会自动递增

INSERT INTO table_test (title,description) VALUES ('a','B');

它抛出错误

com.datastax.driver.core.exceptions.InvalidQueryException: Some partition key parts are missing: id
  com.datastax.driver.core.exceptions.InvalidQueryException: Some partition key parts are missing: id

知道我做错了什么吗。

现在使用()函数

In the coordinator node, generates a new unique timeuuid in milliseconds when the statement is executed. The timestamp portion of the timeuuid conforms to the UTC (Universal Time) standard. This method is useful for inserting values. The value returned by now() is guaranteed to be unique.

Cassandra 中没有自增选项。

now()函数return一个timeuuid,不是自增。它有两个 bigint 部分 MSB 和 LSB。 MSB 是当前时间戳,LSB 是时钟序列和主机节点 ip 的组合。并且是普遍唯一的

使用以下查询插入:

INSERT INTO table_test (id,title,description) VALUES (now(),'a','B');

来源:http://docs.datastax.com/en/cql/3.3/cql/cql_reference/timeuuid_functions_r.html