Deleting records in a database table does not reduce the size of the table for most types of relational databases. In many database types, it just marks the corresponding records as deleted and their space as ready for reusing. Moreover, the records deletion leads to fragmentation, and thus less efficiency of the table indexes. The table packing physically removes previously deleted records from the table, thus defragmenting it and reducing the storage size.
Packing Local BDE Tables
To pack a local BDE table, choose Table | Utilities | Pack menu.
To pack all Paradox (.DB) and dBase (.DBF) tables in a directory, choose Tools | Database Specific Tools | BDE Tools | Pack All Tables....
Note: BDE must be installed.
Packing Tables in Server Databases
To pack tables in SQL-based database, use a SQL query according to your database documentation. For example, to pack a MySQL table, execute the following database query:
OPTIMIZE TABLE <table_name>
To pack a PostgreSQL table, use the following database query:
VACUUM FULL <table_name>
In Oracle database, you have to allow the row movement for the table, and then shrink space:
ALTER TABLE <table_name> ENABLE ROW MOVEMENT;
ALTER TABLE <table_name> SHRINK SPACE;
If your database does not have a dedicated SQL statement for packing tables, and it is not a local BDE table, you can try these steps (again, check your database documentation):
- Make a copy of the table you want to pack. This copy will not be fragmented.
- Delete the old table.
- Rename the new table giving it the name of the old table.
Notes
- It is recommended to backup the table before packing if possible. You can use duplicating database tables for this.
- Note that in most cases the table will be locked to other processes during the standard defragmentation procedure. If this is done on tables that are actively used, try the alternative of copying the table and transferring data to it in parts.
- If you use a FoxPro table with indexes and non-English text data, you cannot pack it in Database Tour by BDE means.
- After packing a Paradox table, the password protection (if any) is sometimes removed, so check and set it again if needed.




