Skip to main content

Delete a record

Jump to the Code block for a combined complete example.


The following examples will use the setup below to illustrate single record deletion in an Aerospike database.


Just as Create and Update, Delete utilizes write policies that can be defined per transaction.

The following example creates a write policy that enables durable deletes.


Record deletion can also be controlled through expiration, a write policy that defines the time-to-live (ttl), or number of seconds a record will live before being removed by the server. The default ttl is to live forever.

Refer to Data Retention for more information.

Delete a record

Default policy

Aerospike deletes a record efficiently by only dropping the primary index entry. The record space on device is recovered during garbage collection.

The following example shows how to delete a record using the default write policy.


Using the default write policy could result in having previously persisted versions of deleted objects resurrected upon a cold restart of the namespace. See Durable Deletes below for more information on preventing zombie records.


Updating a bin value to null, when it is the only bin in the record, deletes the record. See Delete a Bin for information on setting a bin value to null.

Durable deletes

When a transaction results in deletion of a record and the durable delete write policy is set to true, a tombstone record is written to disk to prevent previous versions of the record from returning during a cold restart. Refer to Durable Deletes for more information.

The following example uses the write policy set above to durably delete a record.

Code block

Expand this section for a single code block to durably delete a record