# Could you please give description how updates works in aerospike?

**URL:** <https://discuss.aerospike.com/t/could-you-please-give-description-how-updates-works-in-aerospike/5527>\
**Category:** General Discussion\
**Created:** [September 19, 2018, 11:57am UTC](https://discuss.aerospike.com/t/could-you-please-give-description-how-updates-works-in-aerospike/5527 "2018-09-19T11:57:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlad10](https://avatars.discourse-cdn.com/v4/letter/v/e47774/32.png) [@vlad10](https://discuss.aerospike.com/u/vlad10)\
**Post date:** [September 19, 2018, 11:57am UTC](https://discuss.aerospike.com/t/could-you-please-give-description-how-updates-works-in-aerospike/5527/1 "2018-09-19T11:57:54Z")

</div>

Could you please give description how updates works in Aerospike?

I mean,updates in Aerospike changes only part (bin value) of a record? Or update creates new record and inserts changed values in it?

Thank you!

---

<div class="post-metadata">

**Author:** ![meher](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/meher/32/1644_2.png) [@meher](https://discuss.aerospike.com/u/meher)\
**Post date:** [September 20, 2018, 12:08pm UTC](https://discuss.aerospike.com/t/could-you-please-give-description-how-updates-works-in-aerospike/5527/2 "2018-09-20T12:08:11Z")

</div>

An update to an existing record will read the previous value of the record, replace/add bins that are changed/added and will re-write the whole record.

---

<div class="post-metadata">

**Author:** ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)\
**Post date:** [September 20, 2018, 4:19pm UTC](https://discuss.aerospike.com/t/could-you-please-give-description-how-updates-works-in-aerospike/5527/3 "2018-09-20T16:19:07Z")

</div>

There’s no explicit update. There are write operations such as `put()` and many atomic operations on specific data types, for example `add()` to a bin with an integer data type.

You can control the behavior through the client’s records exists write policy (in the Java client it’s [`RecordExistsAction`](https://www.aerospike.com/apidocs/java/com/aerospike/client/policy/RecordExistsAction.html) of [`WritePolicy`](https://www.aerospike.com/apidocs/java/com/aerospike/client/policy/WritePolicy.html)). The default is an upsert behavior ([`UPDATE`](https://www.aerospike.com/apidocs/java/com/aerospike/client/policy/RecordExistsAction.html#UPDATE)) where if the record / bin aren’t present they will be created by the write operation. If they do exist, the bin values in the write operation will overwrite/operation on the existing bin (comparing `put()` with `add()`).

The other values (`CREATE_ONLY`, `UPDATE_ONLY`) work more like SQL’s `INSERT` and `UPDATE`. They’re explicitly one or the other. If you use `CREATE_ONLY` and the record already exists you’ll get an exception with the [`KEY_EXISTS_ERROR`](https://github.com/aerospike/aerospike-client-java/blob/master/client/src/com/aerospike/client/ResultCode.java#L99-L103) result code.

---

<div class="post-metadata">

**Author:** ![vlad10](https://avatars.discourse-cdn.com/v4/letter/v/e47774/32.png) [@vlad10](https://discuss.aerospike.com/u/vlad10)\
**Post date:** [September 27, 2018, 4:40am UTC](https://discuss.aerospike.com/t/could-you-please-give-description-how-updates-works-in-aerospike/5527/4 "2018-09-27T04:40:11Z")

</div>

Thank you!
