【发布时间】:2018-07-31 08:13:38
【问题描述】:
我想从扳手表中删除一行或所有行。表的主键是 int64。我不想删除表并重新创建它。我使用 google 提供的 Java 教程作为指导(我不是 Java 程序员 - 自产品首次问世以来一直是 MS SQL Server 开发人员)。这是我的代码。没有行被删除,也没有抛出错误。
static void perfmonTestDelete(DatabaseClient dbClient) {
LocalDateTime datetimeStart = LocalDateTime.now();
LocalDateTime datetimeEnd;
Mutation.delete("productPerfmon",KeySet.all());
datetimeEnd = LocalDateTime.now();
long diffInSeconds = java.time.Duration.between(datetimeStart, datetimeEnd).getSeconds();
System.out.println("DurationInSeconds:" + diffInSeconds);
}
这是我要从中删除的表中填充 10 行的代码:
static void perfmonTest(DatabaseClient dbClient) {
LocalDateTime datetimeStart = LocalDateTime.now();
LocalDateTime datetimeEnd;
List<Mutation> mutations = new ArrayList<>();
for (int i = 0; i < 10; i++) {
mutations.add(Mutation.newInsertBuilder("productPerfmon")
.set("product_id")
.to(i)
.set("product_code")
.to("test")
.set("product_code_v")
.to("test_v")
.build());
}
dbClient.write(mutations);
datetimeEnd = LocalDateTime.now();
long diffInSeconds = java.time.Duration.between(datetimeStart, datetimeEnd).getSeconds();
System.out.println("DurationInSeconds:" + diffInSeconds);
}
感谢任何帮助。
【问题讨论】:
标签: google-cloud-platform google-cloud-spanner