Toad World® Forums

How to create/modify foreign keys in Toad?


#1

Following this post, we are still evaluating Toad (6.5.0.3001). I have tried to perform some database design tasks today. Everything worked acceptable apart from foreign keys. There seems to be no way to look at them or edit them in design mode. Alter table window shows foreign keys in constraints section but without showing related tables. So editing and creating foreign keys there fails. There is only one reference for this topic in help. I love how Access allows to edit these relationships. Unfortunately MS has dropped adp support in the latest version. Any ideas how to edit/design foreign keys in Toad?


#2

Hi akrouglov,

to create or modify a foreign key on a table with TOAD for SQL Server 6.5. you must to select tables and on it press right button to select - alter table - .

In alter table dialog, select on the left side - CONSTRAINTS - . After this you can create, modify or delete a foreign key.

I attach a screenshot of this :

toad_fk.jpeg

To create a new FK press add button under table constraints list and select in field - constraints type - Foreign Key. At this point you can select table in - primary table - to reference with foreign key and create a reference in master table column.

I hope this can help you .

Best regards,

Sergio


#3

Hello Sergio,

Thank you for the prompt help.

There are two tables and two fields in each relationship: primary table with primary key and foreign table with foreign key field. This window you are showing allows to select only one table and one key, so it is useless. Also it does not show any table for existing foreign key. The only way to view a foreign key I have found is to script tab.


#4

Hello ,

you are right. In Toad SS 6.5 it doesn’t show existing fk.

I try the same steps in TOAD SS 6.6 Beta and in this version the problem doesn’t appear. FK are shows correctly.

If you want you can download beta version of TOAD and try this.

Best regards,

Sergio


#5

Hello Sergio,

SQL Server 2008 R2 (@@VERSION: Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64) Jun 17 2011 00:54:03 Copyright © Microsoft Corporation Data Center Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor) ). Toad version is 6.6 Beta 516.
No luck adding foreign key:

On creation I have selected REFILL_REQUEST_ID as a foreign key. But Toad apparently tries to use ID as foreign key column :frowning:


#6

Hi Anton,

have you selected the correct field in - master Table Column ?

From the screenshot that you attach I never see any value in this field…

If you wnt to create a FK you must first select Primary table and after the correct field to create FK in - Master Table Column- .

Best regards,

Sergio


#7

Hello Sergio,

Exactly - I have not selected master table column.It was the cause of problem. It works now.


#8

Hi Anton,

good news from you.

I’m glad to help you to solve your problem.

Best regards,

Sergio