Skip to content

ZeroFile

See Also: Erasefile

Purpose

To erase all data from a database table, leaving the empty table definition in place.

Syntax

zerofile
table

What It Does

zerofile erases all data from the specified table (provided it is open) while maintaining the table definition unchanged. After a zerofile command, the number of records in the table is zero.

zerofile customer

In this example, all record data in the database table customer is deleted. The table definition of customer remains intact for future use.

Once a zerofile command has been executed, the only way to restore the data is from a backup copy of the table.

Notes

  • Be extremely careful when using this command. It is very powerful, and if used improperly, could destroy valuable data.

  • You should never use the zerofile command in a multi-user situation when another user may have the same table open. Doing so could result in a corrupted table.

  • zerofile is useful for removing experimental or sample data from database tables and for reinitializing a database for a new period. However, because it erases all data, zerofile does not allow balances to be carried forward to the next period in the table, nor any other data. Again, use the command with care.

  • If you wish to actually delete a disk file, use the erasefile command. zerofile merely removes all data from a database table, rather than erasing disk files.

  • You can pass the table's logical name or table number (in the filelist) to the zerofile command.

  • This command should not be used within a transaction; it will cause an error. A transaction starts with a begin_transaction command and ends with end_transaction.