public sealed class Mutation : IMessage<Mutation>, IEquatable<Mutation>, IDeepCloneable<Mutation>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud Spanner v1 API class Mutation.
A modification to one or more Cloud Spanner rows. Mutations can be
applied to a Cloud Spanner database by sending them in a
[Commit][google.spanner.v1.Spanner.Commit] call.
public Mutation.Types.Write InsertOrUpdate { get; set; }
Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then
its column values are overwritten with the ones provided. Any
column values not explicitly written are preserved.
When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all NOT
NULL columns in the table must be given a value. This holds true
even when the row already exists and will therefore actually be updated.
Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is
deleted, and the column values provided are inserted
instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not
explicitly written become NULL.
In an interleaved table, if you create the child table with the
ON DELETE CASCADE annotation, then replacing a parent row
also deletes the child rows. Otherwise, you must delete the
child rows before you replace the parent row.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eMutation\u003c/code\u003e class in the Google Cloud Spanner v1 API allows for modifications to one or more Cloud Spanner rows, which can be applied to a database via a \u003ccode\u003eCommit\u003c/code\u003e call.\u003c/p\u003e\n"],["\u003cp\u003eThe most recent version of this class is \u003ccode\u003e5.0.0-beta05\u003c/code\u003e, with several prior versions listed for access, including both beta and stable releases going back to version 3.5.0.\u003c/p\u003e\n"],["\u003cp\u003eThis class provides various row manipulation operations, including \u003ccode\u003eInsert\u003c/code\u003e, \u003ccode\u003eInsertOrUpdate\u003c/code\u003e, \u003ccode\u003eReplace\u003c/code\u003e, \u003ccode\u003eUpdate\u003c/code\u003e, and \u003ccode\u003eDelete\u003c/code\u003e, each serving a specific purpose in managing row data.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eMutation\u003c/code\u003e implements several interfaces, including \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, indicating its capabilities in message handling, equality comparison, deep cloning, and buffer management.\u003c/p\u003e\n"],["\u003cp\u003eThere are two constructors for this class, one default constructor, and another constructor that takes another \u003ccode\u003eMutation\u003c/code\u003e as a parameter, and a variety of property types each with different values and descriptions.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Spanner v1 API - Class Mutation (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.Mutation)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/5.0.0/Google.Cloud.Spanner.V1.Mutation)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.6.0/Google.Cloud.Spanner.V1.Mutation)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.5.0/Google.Cloud.Spanner.V1.Mutation)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.4.0/Google.Cloud.Spanner.V1.Mutation)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.3.0/Google.Cloud.Spanner.V1.Mutation)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.2.0/Google.Cloud.Spanner.V1.Mutation)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.1.0/Google.Cloud.Spanner.V1.Mutation)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.0.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.15.1/Google.Cloud.Spanner.V1.Mutation)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.14.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.13.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.12.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.11.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.10.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.9.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.8.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.7.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.6.0/Google.Cloud.Spanner.V1.Mutation)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.5.0/Google.Cloud.Spanner.V1.Mutation) \n\n public sealed class Mutation : IMessage\u003cMutation\u003e, IEquatable\u003cMutation\u003e, IDeepCloneable\u003cMutation\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Spanner v1 API class Mutation.\n\nA modification to one or more Cloud Spanner rows. Mutations can be\napplied to a Cloud Spanner database by sending them in a\n\\[Commit\\]\\[google.spanner.v1.Spanner.Commit\\] call. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e Mutation \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[Mutation](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.Mutation), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[Mutation](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.Mutation), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[Mutation](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.Mutation), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Spanner.V1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.V1.dll\n\nConstructors\n------------\n\n### Mutation()\n\n public Mutation()\n\n### Mutation(Mutation)\n\n public Mutation(Mutation other)\n\nProperties\n----------\n\n### Delete\n\n public Mutation.Types.Delete Delete { get; set; }\n\nDelete rows from a table. Succeeds whether or not the named\nrows were present.\n\n### Insert\n\n public Mutation.Types.Write Insert { get; set; }\n\nInsert new rows in a table. If any of the rows already exist,\nthe write or transaction fails with error `ALREADY_EXISTS`.\n\n### InsertOrUpdate\n\n public Mutation.Types.Write InsertOrUpdate { get; set; }\n\nLike \\[insert\\]\\[google.spanner.v1.Mutation.insert\\], except that if the row already exists, then\nits column values are overwritten with the ones provided. Any\ncolumn values not explicitly written are preserved.\n\nWhen using \\[insert_or_update\\]\\[google.spanner.v1.Mutation.insert_or_update\\], just as when using \\[insert\\]\\[google.spanner.v1.Mutation.insert\\], all `NOT\nNULL` columns in the table must be given a value. This holds true\neven when the row already exists and will therefore actually be updated.\n\n### OperationCase\n\n public Mutation.OperationOneofCase OperationCase { get; }\n\n### Replace\n\n public Mutation.Types.Write Replace { get; set; }\n\nLike \\[insert\\]\\[google.spanner.v1.Mutation.insert\\], except that if the row already exists, it is\ndeleted, and the column values provided are inserted\ninstead. Unlike \\[insert_or_update\\]\\[google.spanner.v1.Mutation.insert_or_update\\], this means any values not\nexplicitly written become `NULL`.\n\nIn an interleaved table, if you create the child table with the\n`ON DELETE CASCADE` annotation, then replacing a parent row\nalso deletes the child rows. Otherwise, you must delete the\nchild rows before you replace the parent row.\n\n### Update\n\n public Mutation.Types.Write Update { get; set; }\n\nUpdate existing rows in a table. If any of the rows does not\nalready exist, the transaction fails with error `NOT_FOUND`."]]