Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this article
Applies to: ✅ Azure Data Explorer
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.
.delete
[async
] table
TableName records
[with
(
propertyName =
propertyValue [,
...])
] <|
Predicate
Learn more about syntax conventions.
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. |
Note
The following restrictions apply to the Predicate:
- The predicate should have at least one
where
operator. - The predicate can only use the following operators:
extend
,where
andproject
. - The predicate can't use
externaldata
.
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 . |
The output of the command contains information about which extents were replaced.
To delete all the records that contain data of a given user:
.delete table MyTable records <| MyTable | where UserId == 'X'
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'
When soft delete is executed on materialized views, the same concepts and limitations apply.
.delete
[async
] materialized-view
MaterializedViewName records
[with
(
propertyName =
propertyValue [,
...])
] <|
Predicate
Learn more about syntax conventions.
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. |
Note
The same restrictions on the Predicate mentioned for table apply here as well. Soft delete might fail in case of conflicts with the materialization process running in the background. Retrying the operation can help in this case. To avoid conflicts, you can disable the materialized view before executing soft delete, and re-enable it when the operation completes. Usage of function materialized_view() is not allowed in Predicate.
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 . |
To delete all the materialized view records that contain data of a given user:
.delete materialized-view MyMaterializedView records <| MyMaterializedView | where UserId == 'X'
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'