Add Primary Keys

Search Knowledge Base by Keyword

< Back

The ADDPKEYS Action adds Primary Key Constraints to the Data Subset. It will add all Primary Keys specified where

  1. The Primary Key is set to “Active” in Tables Sheet of the Control Spreadsheet.
  2. The relevant Foreign Key table and Primary key table is set to “Active” in the Tables Sheet.

The PREPENV action creates Indices in the Target Data, but does not create the Primary Key constraints. The SUBSET action will not create them either.

If you have run SUBSET and are happy with the results, you can then add your Primary Keys using the ADDPKEYS Action.

This adds the Primary Keys that are set to “Active” in the Tables sheet of the Control Spreadsheet. Instructions for editing the Tables sheet are available here.

To run ADDDPKEYS, first open your re-usable .cmd script in a text editor.

If you have already configured a .cmd script for one Subset Action and wish to edit and re-use that script, you should only need to specify “ADDPKEYS” for  -parAction=””:

Data Subsetting

Otherwise, configure all mandatory parameters in the .cmd script.

You can also specify optional parameters at this stage.

Make sure your Control Spreadsheet, the Subset Report, and any Log Files are closed.

Run the script to add the Primary Keys.

Check the Log File and Subset Report at this stage, to check that the Actions have performed correctly.

Next, check your Database to make sure the Primary Keys constraints have been added. You can additionally run the VALIDATEPKEYS Action to make sure all Primary Keys are unique.

If the Primary Keys are incorrect, you can perform the DROPPKEYS Action to remove them and add a new set.