Solved

Table Structures (Foreign Keys)

Posted on 1999-01-28
7
240 Views
Last Modified: 2010-04-06
Would like to know if there is an easy way to look at a tables structure and identify which fields are setup as foreign keys.  User Delphi with SQL.  Any assistance would be greatly appreciated
0
Comment
Question by:GGriffith
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1363714
Hi GGriffith,

what SQL-ServerSystem (Oracle, Interbase ...)?

meikl
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363715
you might be able to do something like this:

with TableOrQuery do
  for I := 0 to FieldCount - 1 do
    if Fields[I].FieldKind = fkLookup then
      //////Do Whaever here.  This would be a foreign key
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1363716
Hi heathprovost,

really? is this kind not used for the lookup-components?

meikl
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:GGriffith
ID: 1363717
Using Sybase SQL Anywhere....on a Windows 95/98/NT platform...
I looked at using the FIELDKIND, but it doesn't seem to offer a way to identify the field as being a foreign key...Any other ideas?

0
 
LVL 1

Accepted Solution

by:
velev earned 50 total points
ID: 1363718
most of the SQL servers ()has system tables in
which they stores information about relations triggers, dependencies, domains, foreign keys and so on
you have to find out this tables for your server ( with SQLExpolorer for example (in view menu click show system tables))
and retrieve info from them (be carefull with "write" operation in this tables)
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363719
Sorry about that, I wasnt thinking clearly, hadnt had my coffee yet :)

Heath
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363720
One other thought.  Many RDBMS's by default will name foreign keys a certain way (i.e. FK_something).  If this is the case with your system you could cycle through all of the IndexDefs and check the name property.  Just a thought

Heath
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now