英文:
Does insert_or_update on a parent table delete child rows in GCP Spanner?
问题
如果我在一个已经存在的PARENT
表中执行insert_or_update
(即执行update
)操作,Spanner文档中似乎找不到对此的明确答案,那么相应的交错表的现有子行会被删除还是保留?
英文:
I can't seem to find a definitive answer to this in the documentation for Spanner, but if I insert_or_update
a row in a PARENT
table that already exists (so update
) are existing child rows of an interleaved table deleted or preserved?
答案1
得分: 1
insert_or_update
突变将会:
- 如果目标表中的行尚不存在,将插入一行新记录。
- 如果目标表中的行已存在,将更新现有记录。
- 在上述两种情况下都不会触及任何子行。基本上与
insert
和update
的行为相同。
如果您想删除任何子行并用新值替换父行,可以使用 replace
突变类型。
更多详细信息请参考:https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Mutation。
英文:
An insert_or_update
mutation will:
- Insert a new row in the table that you are operating on if the row does not yet exist.
- Update the existing row if the row does exist.
- Keep all child rows untouched in both the above scenarios. It basically behaves the same as how
insert
andupdate
would behave.
You can use the replace
mutation type if you want to delete any child rows and replace the parent row with a new value.
See https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Mutation for more details.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论