Data soft delete command

This article describes the data soft delete commands.

To soft delete individual records without a system guarantee that the storage artifacts containing these records are deleted as well, use the following command. This command marks records as deleted but doesn’t necessarily delete the data from storage artifacts. For more information, see Soft delete.

To delete individual records with a system guarantee that the storage artifacts containing these records are deleted as well, see Data purge.

Syntax

.delete [async] table TableName records [with ( propertyName = propertyValue [, …])] <| Predicate

Parameters

NameTypeRequiredDescription
asyncstringIf specified, indicates that the command runs in asynchronous mode.
TableNamestring✔️The name of the table from which to delete records.
propertyName, propertyValuestringA comma-separated list of key-value property pairs. See supported properties.
Predicatestring✔️The predicate that returns records to delete, which is specified as a query. See note.

Supported properties

NameTypeDescription
whatifboolIf true, returns the number of records that will be deleted in every shard, without actually deleting any records. The default is false.

Returns

The output of the command contains information about which extents were replaced.

Example: delete records of a given user

To delete all the records that contain data of a given user:

.delete table MyTable records <| MyTable | where UserId == 'X'

Example: check how many records would be deleted from a table

To determine the number of records that would be deleted by the operation without actually deleting them, check the value in the RecordsMatchPredicate column when running the command in whatif mode:

.delete table MyTable records with (whatif=true) <| MyTable | where UserId == 'X'

.delete materialized-view records - soft delete command

When soft delete is executed on materialized views, the same concepts and limitations apply.

Syntax - materialized views

.delete [async] materialized-view MaterializedViewName records [with ( propertyName = propertyValue [, …])] <| Predicate

Parameters - materialized views

NameTypeRequiredDescription
asyncstringIf specified, indicates that the command runs in asynchronous mode.
MaterializedViewNamestring✔️The name of the materialized view from which to delete records.
propertyName, propertyValuestringA comma-separated list of key-value property pairs. See supported properties.
Predicatestring✔️The predicate that returns records to delete. Specified as a query.

Supported properties - materialized views

NameTypeDescription
whatifboolIf true, returns the number of records that will be deleted in every shard, without actually deleting any records. The default is false.

Example - materialized views

To delete all the materialized view records that contain data of a given user:

.delete materialized-view MyMaterializedView records <| MyMaterializedView | where UserId == 'X'

Example: check how many records would be deleted from a materialized view

To determine the number of records that would be deleted by the operation without actually deleting them, check the value in the RecordsMatchPredicate column while running the command in whatif mode:

.delete materialized-view MyMaterializedView records with (whatif=true) <| MyMaterializedView | where UserId == 'X'