The DELETE BACKUPSET/ARCHIVELOG_PIECE statement is used to clean up a specified data backup set or archive log piece.
Limitations and considerations
When you use the
DELETE BACKUPSETstatement to clean up a specified data backup set, note the following:You must not break the dependency between data backups. If a data backup is depended on by an incremental backup, you can delete the data backup only after you delete all incremental backups that depend on it.
If you need to specify multiple
backup_set_idvalues for cleanup, allbackup_set_idvalues must be in the same backup path. You cannot clean up data backups in multiple paths in one statement.For the current backup path, you must retain at least one latest full data backup that can be used for recovery. In other words, you can delete other backup sets in the backup set before the latest full data backup only after you retain the latest full data backup.
If the data backup set to be deleted is not in the current backup path, OceanBase Database must have access permissions to the corresponding backup path.
When you use the
DELETE ARCHIVELOG_PIECEstatement to clean up a specified archive log piece, note the following:You must clean up archive log pieces in sequence.
When you clean up a piece in the current archive path, the piece must not be depended on by any data backup in the current data backup path.
If you need to specify multiple
piece_idvalues for cleanup, allpiece_idvalues must be in the same archive path. You cannot clean up archive log pieces in multiple paths in one statement.
Privilege requirements
The sys tenant's root user (root@sys) or the administrator of each tenant must execute this statement. Specifically:
- In MySQL mode, the default administrator is the
rootuser. - In Oracle mode, the default administrator is the
SYSuser.
Syntax
ALTER SYSTEM DELETE delete_action [TENANT [=] tenant_name];
delete_action:
BACKUPSET backup_set_id[,backup_set_id,...]
| ARCHIVELOG_PIECE piece_id[,piece_id,...]
Parameters
Parameter |
Description |
|---|---|
| backup_set_id | The ID of the data backup set to be deleted. You can query this value from the CDB_OB_BACKUP_SET_FILES view (for the sys tenant) or the DBA_OB_BACKUP_SET_FILES view (for a user tenant). In one statement, you can specify multiple data backup sets. Separate different backup_set_id values with commas. If you specify multiple backup_set_id values for cleanup, all backup_set_id values must be in the same backup path. You cannot clean up data backups in multiple paths in one statement. |
| piece_id | The ID of the archive log piece to be deleted. You can query this value from the CDB_OB_ARCHIVELOG_PIECE_FILES view (for the sys tenant) or the DBA_OB_ARCHIVELOG_PIECE_FILES view (for a user tenant). In one statement, you can specify multiple archive log pieces. If you specify multiple piece_id values for cleanup, all piece_id values must be in the same archive path. You cannot clean up archive log pieces in multiple paths in one statement. |
| tenant_name | The name of the user tenant whose backup data is to be cleaned up. This parameter is optional and is required only when you execute this statement as the sys tenant. |
Examples
As the sys tenant
Clean up a specified data backup set.
The sys tenant deletes the data backup set with the
backup_set_idvalue of 3 in themysql001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE BACKUPSET 3 TENANT = mysql001;The sys tenant deletes three data backup sets with the
backup_set_idvalues of 1, 2, and 4 in themysql001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE BACKUPSET 1,2,4 TENANT = mysql001;
Clean up a specified archive log piece.
The sys tenant deletes the archive log piece with the
piece_idvalue of 5 in themysql001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 5 TENANT = mysql001;The sys tenant deletes four archive log pieces with the
piece_idvalues of 6, 7, 8, and 9 in themysql001tenant.obclient(root@sys)[(none)]> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 6,7,8,9 TENANT = mysql001;
As a user tenant
Clean up a specified data backup set.
The user tenant deletes the data backup set with the
backup_set_idvalue of 3 in the current tenant.obclient> ALTER SYSTEM DELETE BACKUPSET 3;The user tenant deletes four data backup sets with the
backup_set_idvalues of 1, 2, and 4 in the current tenant.obclient> ALTER SYSTEM DELETE BACKUPSET 1,2,4;
Clean up a specified archive log piece.
The user tenant deletes the archive log piece with the
piece_idvalue of 5 in the current tenant.obclient> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 5;The user tenant deletes four archive log pieces with the
piece_idvalues of 6, 7, 8, and 9 in the current tenant.obclient> ALTER SYSTEM DELETE ARCHIVELOG_PIECE 6,7,8,9;
