.undo drop table.undo drop table

.undo drop table 命令将删除表操作还原为特定的数据库版本。The .undo drop table command reverts a drop table operation to a specific database version.

语法Syntax

.undo drop table TableName [as NewTableName] version=v DB_MajorVersion.DB_MinorVersion.undo drop table TableName [as NewTableName] version=v DB_MajorVersion.DB_MinorVersion

该命令必须在数据库上下文中执行。The command must be executed with database context.

返回Returns

此命令:This command:

  • 返回原始表盘区列表Returns the original table extents list
  • 为每个盘区指定盘区包含的记录数Specifies for each extent the number of records the extent contains
  • 恢复操作成功或失败都返回Returns if the recover operation succeeded or failed
  • 如果相关,则返回失败原因。Returns the failure reason, if relevant.
ExtentIdExtentId NumberOfRecordsNumberOfRecords 状态Status FailureReasonFailureReason
ef296c9e-d75d-44bc-985c-b93dd2519691ef296c9e-d75d-44bc-985c-b93dd2519691 100100 已恢复Recovered
370b30d7-cf2a-4997-986e-3d05f49c9689370b30d7-cf2a-4997-986e-3d05f49c9689 10001000 已恢复Recovered
861f18a5-6cde-4f1e-a003-a43506f9e8da861f18a5-6cde-4f1e-a003-a43506f9e8da 855855 无法恢复盘区Unable to recover extent 盘区容器:找不到 4b47fd84-c7db-4cfb-9378-67c1de7bf154,此盘区已从存储中删除,无法恢复Extent container: 4b47fd84-c7db-4cfb-9378-67c1de7bf154 wasn't found, the extent was removed from storage and can't be restored

示例Examples

// Recover TestTable table to database version 24.3
.undo drop table TestTable version="v24.3"
// Recover TestTable table to database version 10.3 with new table name, NewTestTable (can be used if a table with the same name was already created since the drop)
.undo drop table TestTable as NewTestTable version="v10.3"

如何查找所需的数据库版本How to find the required database version

可以使用 .show journal 命令在执行删除操作之前找到数据库版本:You can find the database version before the drop operation was executed by using the .show journal command :

.show database TestDB journal | where Event == "DROP-TABLE" and EntityName == "TestTable" | project OriginalEntityVersion
OriginalEntityVersionOriginalEntityVersion
v24.3v24.3

限制Limitations

如果对此数据库执行了 Purge 命令,则不能将 undo drop table 命令执行到清除执行之前的版本。If a Purge command was executed on this database, the undo drop table command can't be executed to a version earlier to the purge execution.

仅当尚未达到数据库所在盘区容器的硬删除期时,才可以恢复盘区。Extent can be recovered only if the hard delete period of the extent container it resides in wasn't reached yet.

该命令需要数据库管理员权限The command requires database admin permission.