Manage foreign keys (Sybase Central)

In Sybase Central, the foreign key of a table appears on the Constraints tab, which is located on the right pane when a table is selected.

You create a foreign key relationship when you create the child table (that is, prior to inserting data in the child table). The foreign key relationship then acts as a constraint; for new rows inserted in the child table, the database server checks to see if the value you are inserting into the foreign key column matches a value in the primary table's primary key.

After you have created a foreign key, you can keep track of it on each table's Constraints tab in the right pane; this tab displays any foreign tables that reference the currently selected table.

To create a new foreign key (Sybase Central)
  1. Connect to the database as a user with DBA authority, or as the owner of the table.

  2. In the left pane, double-click Tables.

  3. Right-click the table and choose New » Foreign Key.

  4. Follow the instructions in the Create Foreign Key Wizard.

To delete a foreign key (Sybase Central)
  1. Connect to the database as a user with DBA authority, or as the owner of the table.

  2. In the left pane, double-click Tables.

  3. Select the table for which you want to delete a foreign key.

  4. In the right pane, click the Constraints tab.

  5. Right-click the foreign key and choose Delete.

  6. Click Yes.

For any given table, you can also view a list of tables that reference the table using a foreign key.

To display a list of tables that reference a given table (Sybase Central)
  1. Connect to the database as a user with DBA authority, or as the owner of the table.

  2. In the left pane, double-click Tables.

  3. Click the table.

  4. In the right pane, click the Referencing Constraints tab.

Tips

When you create a foreign key using the wizard, you can set properties for the foreign key. To view properties after the foreign key is created, select the foreign key on the Constraints tab and then choose File » Properties.

You can view the properties of a referencing foreign key by selecting the table on the Referencing Constraints tab and then choosing File » Properties.