Data soft delete command
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
| Name | Type | Required | Description |
|---|---|---|---|
async | string | If specified, indicates that the command runs in asynchronous mode. | |
| TableName | string | ✔️ | The name of the table from which to delete records. |
| propertyName, propertyValue | string | A comma-separated list of key-value property pairs. See supported properties. | |
| Predicate | string | ✔️ | The predicate that returns records to delete, which is specified as a query. See note. |
Supported properties
| Name | Type | Description |
|---|---|---|
whatif | bool | If 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
| Name | Type | Required | Description |
|---|---|---|---|
async | string | If specified, indicates that the command runs in asynchronous mode. | |
| MaterializedViewName | string | ✔️ | The name of the materialized view from which to delete records. |
| propertyName, propertyValue | string | A comma-separated list of key-value property pairs. See supported properties. | |
| Predicate | string | ✔️ | The predicate that returns records to delete. Specified as a query. |
Supported properties - materialized views
| Name | Type | Description |
|---|---|---|
whatif | bool | If 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'
Related content
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.