The Table_AutoShrink() function shrinks a data table and rebuilds the table’s indexes if the current database manager is capable of performing such operations. The Table_GetAutoShrinkMode() function must be used prior to this function to ascertain whether the current database manager has these capabilities.


Table_AutoShrink(table table_name)


table table_name The name of the table you want to shrink.

Return value

An integer containing the error code returned by the database manager. A return value of zero indicates no error occurred. Consult your database manager’s reference manual for a list of error codes.


Since some database managers have provisions for performing table shrinks, this function transfers the shrink process to the database manager. Currently, c-tree and Pervasive.SQL tables can be shrunk using Table_AutoShrink().

Shrinking is the process of removing unused space in a data table. The removal of unused space in this manner is called a “shrink” because the table will invariably be smaller after the unused space is removed. The shrink process copies the contents of the original table to a secondary table. After the copy is complete, the original table is deleted and the secondary table is renamed to take the place of the first table. The process of copying records to the new table eliminates the unused space.

The c-tree Plus database manager also rebuilds the table’s indexes during the shrink. Indexes are stored in the .IDX file with the same name to the left of the extension as the data table. You can use Table_RebuildIndexes() if you want to rebuild the indexes without shrinking the table.

We recommend that you shrink data tables frequently as part of periodic application maintenance. This will help ensure data integrity and optimal application performance. It will also optimize disk space usage where tables are stored.

Documentation Feedback