sp_dboption

The sp_dboption system procedure supports the ability to remove residual data from deletions in SAP ASE.

Syntax

The syntax to enable the removal of residual data at the database level is:
sp_dboption dbname, "erase residual data", true

Examples

The following examples use these two tables:
  • create table t1 (col1 int) with "erase residual data" on
  • create table t2 (col1 int) with "erase residual data" off

Example 1

The option to erase residual data is turned on for table t1 because it is set at the database level, so that both the drop table and truncate table commands for t1 result in the cleanup of all residual data from its pages.

Table t2, however, has the erase residual data option turned off explicitly, as it was created with the "erase residual data off" clause. Residual data is not removed, even though the "erase residual data" option is set to true at the database level. As a result, residual data remains, even after running drop table and truncate table on t2:
create database db1
go
sp_dboption db1, "erase residual data", true
go
use db1
go
create table t1 (col int)
go
insert t1 values ...
go
create table t2 (col1 int, col2 char(10)) with "erase residual data" off
go
truncate table t1
go
drop table t1
go
truncate table t2
go
drop table t2
go

Example 2

In this example:
  • Table t1 does not have "erase residual data off" set explicitly, but does have it set at the database level, resulting in the removal of residual data from t1 when you run truncate table t1.
  • Table t2 has the "erase residual data" option set at creation, because the option was set at the database level. This results in the removal of residual data from t2 when you run truncate table t2.
  • Table t3 is marked with "erase residual data off" explicitly, so that even though sp_dboption sets "erase residual data" to true, residual data is not removed when SAP ASE runs truncate table t3.
create database db1
go
use db1
go
create table t1 (col int)
go
sp_dboption db1, "erase residual data", true
go
create table t2 (col1 int, col2 char(10))
go
create table t3 (col1 int, col2 char(10)) with "erase residual data" off
go
truncate table t1
go
truncate table t2
go
truncate table t3
go

Usage

When you enable this setting at the database level, any operation that results in deallocation is followed by the cleaning of its pages. By default, this option is disabled.

Note: Using this option can have a major impact on performance because you do not have control at the granular level.

Permissions

To set the database-level option using sp_dboption, the user must be a system administrator or database owner.

Related concepts
create table for Residual Data Removal
set