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
zerofilecommand in a multi-user situation when another user may have the same table open. Doing so could result in a corrupted table. -
zerofileis 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,zerofiledoes 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
erasefilecommand.zerofilemerely 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
zerofilecommand. -
This command should not be used within a transaction; it will cause an error. A transaction starts with a
begin_transactioncommand and ends withend_transaction.