从 Azure 数据资源管理器中删除数据Delete data from Azure Data Explorer

Azure 数据资源管理器支持本文中所述的各种删除方案。Azure Data Explorer supports various delete scenarios described in this article.

使用保留策略删除数据Delete data using the retention policy

Azure 数据资源管理器会根据保留策略自动删除数据。Azure Data Explorer automatically deletes data based on the retention policy. 此方法是最有效且无障碍的数据删除方式。This method is the most efficient and hassle-free way of deleting data. 请在数据库或表级别设置保留策略。Set the retention policy at the database or table level.

假设某个数据库或表的保留期设置为 90 天。Consider a database or table that is set for 90 days of retention. 如果只需要 60 天的数据,请如下所述删除更旧的数据:If only 60 days of data are needed, delete the older data as follows:

alter-merge database <DatabaseName> policy retention softdelete = 60d

alter-merge table <TableName> policy retention softdelete = 60d

通过删除盘区来删除数据Delete data by dropping extents

盘区(数据分片)是数据存储在其中的内部结构。Extent (data shard) is the internal structure where data is stored. 每个盘区可容纳多达数百万条记录。Each extent can hold up to millions of records. 可以使用删除盘区命令逐个或者按组删除盘区。Extents can be deleted individually or as a group using drop extent(s) commands.

示例Examples

你可以删除表中的所有行或只删除特定盘区。You can delete all rows in a table or just a specific extent.

  • 删除表中的所有行:Delete all rows in a table:

    .drop extents from TestTable
    
  • 删除特定盘区:Delete a specific extent:

    .drop extent e9fac0d2-b6d5-4ce3-bdb4-dea052d13b42
    

使用清除删除各个数据行Delete individual rows using purge

可以使用数据清除来删除各个行。Data purge can be used for deleting individuals rows. 删除不是即时的,并且需要大量的系统资源。Deletion isn't immediate and requires significant system resources. 因此,建议仅将其用于合规性方案。As such, it's only advised for compliance scenarios.