Creating a foreign key (Sybase Central)

You can create a foreign key relationship between tables. A foreign key relationship 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.

Prerequisites

You must have DBA authority or be the owner of the table.

Context and remarks

You do not have to create a foreign key when you create a foreign table; the foreign key is created automatically.

 To create a foreign key using Sybase Central
  1. Use the SQL Anywhere 12 plug-in to connect to the database as a user with

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

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

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

  5. Create a foreign key:

    1. Click File » New » Foreign Key.

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

Results

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.

Next

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 click File » Properties.

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

To view the list of tables that reference a given table, select the table in Tables, and then in the right pane, click the Referencing Constraints tab.

 See also