Adding Auto-increment Fields to Existing Tables

Q: I recently used an autoinc field for the first time on a .DBF file. When I added the field (a couple hundred records), each autoinc field was filled in with a number.

Yesterday, I tried the same thing on a .DBF with only 12 records and it refuses to place numbers in the field. Any ideas as to what I might be doing wrong? 

A: The recommended procedure is to copy the structure, add the autoinc to the new table, and append the data. Directly modifying the structure of a table is unwise, unless of course you have a current backup (Murphy strikes when least expected).  The following illustrates the recommended process:

USE oldtable
COPY STRUCTURE TO newtable with production 
// the "with production" gets the production index tags
use newtable exclusive
// modify the structure
append from oldtable

Then you can delete the old table (including the index) and rename the new ones to the old filenames.