Cassandra :

CREATE TABLE student (firstName text , lastName text, score int, PRIMARY KEY (firstName))

Java :

@PartitionKey
private String firstName;

@Column(name = "lastName")
private String lastName;

@Column(name = "score")
private int score;

2个Primary Key

Cassandra :

CREATE TABLE student (firstName text , lastName text, score int, PRIMARY KEY (firstName, lastName))

Java :

@PartitionKey(0)
private String firstName;

@PartitionKey(1)
private String lastName;

@Column(name = "score")
private int score;

查询:

select * from student where firstName = "*"; ✘
select * from student where lastName = "*"; ✖︎
select * from student where firstName ="*" and lastName ="*";  ✔︎
@PartitionKey
private String firstName;

@ClusteringColumn
private String lastName;

@Column(name = "score")
private int score;

查询:

select * from student where firstName = "*"; ✔︎
select * from student where lastName = "*"; ✖︎
select * from student where firstName ="*" and lastName ="*";  ✔︎

相关文章:

  • 2021-10-18
  • 2021-09-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-12-09
  • 2022-12-23
  • 2021-12-09
相关资源
相似解决方案