Tech Tip: Creating New Primary Key fields for existing tables
PRODUCT: 4D | VERSION: 14.0 | PLATFORM: Mac & Win
Published On: October 6, 2014
4D v14's Auto UUID and Auto Increment functions can automatically populate existing records when a new field is created. Taking advantage of this feature, here are two methods to create a new primary key field for existing tables that are populated with data easily.
The first method is to:
- Create a new field for the table and set it as a UUID format with the Auto UUID feature set or the Auto Increment feature set. This will automatically populate each records' new field with a unique value.
- Then the field can be set as a Primary Key. If an automatic field is not set then an error dialogue will appear explaining that the there is a problem with duplicate values due to all of the records' new fields containing a null value.
- Open the structure with a new data file.
- Then add a primary key field to any tables with the Auto UUID or Auto increment feature set.
- Then open any datafile and the tables and records will get automatically populated.