Editing a Foreign Key

Edit a foreign key to change a constraint on column values that depend on another table.

Prerequisites 

Before you can edit a foreign key, be sure that the data server containing the table for which you are creating a foreign key is running, you created and established a connection to the data server, and you opened the table in the Table Schema Editor.

  1. In the Table Schema Editor, select the Constraints tab for the table for which you want to edit the foreign key.
  2. Expand the Foreign Key folder under Constraints in the directory tree, and highlight the foreign key to edit.
  3. Edit the foreign key settings in the Details pane.
    Field Description
    Name Enter a name for the foreign key in the text field.
    Primary Table Specify the database, owner, and table.
    Reference Constraint Specify the type and name of constraint referenced by the foreign key.
    Index Option (SQL Anywhere only) Set the index option. Click Set Clustered Index to open the Set Clustered Index wizard.
    Columns Mapping Shows the mapping of foreign columns to primary columns, including the datatype of each column.
    Action (SQL Anywhere and Sybase IQ only) Specify actions to take on update and on delete.
    Not Null (SQL Anywhere and Sybase IQ only) Disallow null values in foreign-key columns.
    Check on Commit (SQL Anywhere and Sybase IQ only) Override any WAIT_FOR_COMMIT option.
    Comment (SQL Anywhere and Sybase IQ only) (Optional) Specify a comment for the foreign key.
    Match Full Specify the constraint conditions on the values of the referencing columns. If all values in the referencing columns of a referencing row are:
    • Null – the referential integrity condition is true.
    • Non-null – the referential integrity condition is true if there is a referenced row where each corresponding column is equal in the referenced table.
    The referential integrity condition is false when:
    • All values are non-null and not equal, or
    • Some values in the referencing columns of a referencing row are non-null values, while others are null.
  4. Select File > Save from the main menu in WorkSpace.
  5. (Optional) If the Preview Changes dialog appears with the DDL for altering the foreign key, select a save option.
    Option Description
    To execute the changes Click Save.
    To save the DDL to a SQL file Click Save As, enter or select a project or project folder, and specify a file name for the DDL.
Related concepts
Foreign Keys
Related tasks
Creating a Foreign Key
Dropping a Foreign Key

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.