Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Working with Database Objects » Working with tables » Managing foreign keys

Managing foreign keys Next Page

Managing 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. Select the table for which you want to create a foreign key.

  2. Click the Constraints tab in the right pane.

  3. From the File menu, choose New > Foreign Key.

    The Create Foreign Key wizard appears.

  4. Follow the instructions in the wizard.

To delete a foreign key (Sybase Central)
  1. Select the table for which you want to delete a foreign key.

  2. Click the Constraints tab in the right pane.

  3. Select the foreign key you want to delete and then choose Edit > Delete.

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. In the left pane, select the desired table.

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

  3. 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.