如何在Google Cloud Spanner查询中强制使用主键?

huangapple go评论52阅读模式
英文:

How to force using primary key in Google cloud spanner queries?

问题

你可以在这里查看强制在Google Cloud Spanner查询中使用命名索引的示例:https://cloud.google.com/spanner/docs/sql-best-practices#postgresql_2

我想了解如何强制使用主键索引的语法。

英文:

There're examples of forcing a named index in Google cloud spanner queries here: https://cloud.google.com/spanner/docs/sql-best-practices#postgresql_2

I would like to know about the syntax of forcing primary key index.

答案1

得分: 0

你可以像任何其他索引一样引用主键。Cloud Spanner中的主键始终命名为PRIMARY_KEY。因此,可以通过以下方式指示使用主键:

select * from test/*@ FORCE_INDEX=PRIMARY_KEY */;
英文:

You can reference the primary key in the same way as any other index. Primary keys in Cloud Spanner are always named PRIMARY_KEY. So indicating that the primary key should be used can be achieved like this. The link you shared seems to reference the PostgreSQL-dialect of Google Cloud Spanner, so the example uses that dialect:

select * from test/*@ FORCE_INDEX=PRIMARY_KEY */;

huangapple
  • 本文由 发表于 2023年3月31日 18:18:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897382.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定