Enabling replication of truncate table

If you are using Adaptive Server Enterprise version 11.5 or later, you can enable replication of the truncate table command to particular destination database tables when you create or define a subscription.

RSM

See “Input to create a table replication definition subscription” in Replication Server’s plug-in help for instructions on using the truncate table option in Sybase Central.

To create or define a subscription that enables replication of truncate table, log in to Replication Server and enter:

create subscription subscription
	for table_rep_def 
	with replicate at data_server.database
	 ...
	subscribe to truncate table

When truncate table executes at the destination database, Adaptive Server deallocates whole data pages. It does not delete rows one at a time.

NoteReplication Server executes truncate table at the replicate database as the maintenance user. Among the permissions granted to maintenance user is replication_role. If you revoke maintenance user’s replication_role, you cannot replicate truncate table unless the maintenance user has been granted sa_role, the maintenance user owns the table, or the maintenance user is aliased as the Database Owner.

Warm standby applications can copy the execution of truncate table to standby databases without a subscription. Refer to for information about using this feature.

See define subscription and create subscription in Chapter 3, “Replication Server Commands” in the Replication Server Reference Manual for complete command syntax and usage guidelines.

Changing the Status of “subscribe to truncate table”

All subscriptions for a replicate table in a particular database must either support or not support replication of truncate table. You cannot create a subscription that enables replication of truncate table if all existing subscriptions for that table do not support replication of truncate table.

Use the sysadmin apply_truncate_table command to change the status of “subscribe to truncate table” for all subscriptions on a replicate table.

For example, to turn on replication of truncate table for all subscriptions to a replicate table, log in to the replicate Replication Server and execute this command at the isql prompt:

sysadmin apply_truncate_table data_server,
 database, {table_owner| ''}, table_name'on'

where data_server is the name of the replicate data server, database is the name of the replicate database managed by the data server, table_owner is the owner of the replicate table, and table_name is the name of the replicate table.

If you specified a replicate table owner in the replication definition, you must also specify a table owner with the sysadmin apply_truncate_tablecommand. If you did not specify a replicate table owner in the replication definition, enter '' (two single-quote characters) or ““ (two double-quote characters) for the table owner name.

Refer to “sysadmin apply_truncate_table” in Chapter 3, “Replication Server Commands” in the Replication Server Reference Manual for more information about this command.