dbTalk Databases Forums  

List foreign keys

comp.databases.ingres comp.databases.ingres


Discuss List foreign keys in the comp.databases.ingres forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lee
 
Posts: n/a

Default List foreign keys - 07-29-2011 , 06:00 AM






How can I get a list of a table's foreign keys, in Ingres 9.1?

The documentation for 9.1 is no longer on line, and my client
apparently has none, either.

Thanks in anticipation
lee

Reply With Quote
  #2  
Old   
Paul Mason
 
Posts: n/a

Default Re: [Info-Ingres] List foreign keys - 07-29-2011 , 06:44 AM






HELP CONSTRAINT <table_name> will list the constraints on a table,
including the foreign key ones.

HTH
Paul

Quote:
-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com [mailto:info-
ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of Lee
Sent: 29 July 2011 12:01
To: info-ingres (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] List foreign keys

How can I get a list of a table's foreign keys, in Ingres 9.1?

The documentation for 9.1 is no longer on line, and my client
apparently has none, either.

Thanks in anticipation
lee
_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com

http://ext-cando.kettleriverconsulti...fo/info-ingres

Reply With Quote
  #3  
Old   
Lee
 
Posts: n/a

Default Re: List foreign keys - 07-29-2011 , 08:06 AM



Thanks, Paul, but I have to use SQL to perform this task -- via the
Perl DBI. So 'HELP' is a syntax error.

On Jul 29, 12:44*pm, "Paul Mason" <Paul.Ma... (AT) ingres (DOT) com> wrote:
Quote:
HELP CONSTRAINT <table_name> will list the constraints on a table,
including the foreign key ones.

HTH
Paul



-----Original Message-----
From: info-ingres-boun... (AT) kettleriverconsulting (DOT) com [mailto:info-
ingres-boun... (AT) kettleriverconsulting (DOT) com] On Behalf Of Lee
Sent: 29 July 2011 12:01
To: info-ing... (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] List foreign keys

How can I get a list of a table's foreign keys, in Ingres 9.1?

The documentation for 9.1 is no longer on line, and my client
apparently has none, either.

Thanks in anticipation
lee
_______________________________________________
Info-Ingres mailing list
Info-Ing... (AT) kettleriverconsulting (DOT) com

http://ext-cando.kettleriverconsulti...fo/info-ingres

Reply With Quote
  #4  
Old   
Roy Hann
 
Posts: n/a

Default Re: List foreign keys - 07-29-2011 , 08:41 AM



Lee wrote:

Quote:
How can I get a list of a table's foreign keys, in Ingres 9.1?
Rather annoyingly you can't get that information in a convenient form.

The best you can do AFAIK is:

select schema_name, table_name, text_segment
from iiconstraints
where constraint_type = 'R'
order by constraint_name, schema_name, table_name, text_sequence;

You then have to concatenate and parse the text_segments for each
constraint.

It sucks, desperately. :-(

--
Roy

UK Ingres User Association Conference 2012 will be on Tuesday June 19 2012.
*NOTE THE CHANGED DATE* See www.uk-iua.org.uk

Reply With Quote
  #5  
Old   
Ingres Forums
 
Posts: n/a

Default Re: List foreign keys - 07-29-2011 , 08:42 AM



Hi Lee,

You can use sc930 to get the SQL generated by HELP CONSTRAINT
<tablename>.

Jeremy


--
jruffer

Reply With Quote
  #6  
Old   
Ingres Forums
 
Posts: n/a

Default Re: List foreign keys - 07-29-2011 , 08:43 AM



Then you'll have to use system catalogs. Start with these: iiintegrity,
iikey, iiintegrityidx .
Maybe you'll need more, depends what you want to achieve...


--
dejan

Reply With Quote
  #7  
Old   
Roy Hann
 
Posts: n/a

Default Re: List foreign keys - 07-29-2011 , 08:43 AM



Roy Hann wrote:

Quote:
The best you can do AFAIK is:

select schema_name, table_name, text_segment
from iiconstraints
where constraint_type = 'R'
order by constraint_name, schema_name, table_name, text_sequence;
Correction, make that last line:

...order by schema_name, table_name, constraint_name, text_sequence;

--
Roy

UK Ingres User Association Conference 2012 will be on Tuesday June 19 2012.
*NOTE THE CHANGED DATE* See www.uk-iua.org.uk

Reply With Quote
  #8  
Old   
Roy Hann
 
Posts: n/a

Default Re: List foreign keys - 07-29-2011 , 08:47 AM



Roy Hann wrote:

Quote:
Lee wrote:

How can I get a list of a table's foreign keys, in Ingres 9.1?

Rather annoyingly you can't get that information in a convenient form.
In my eagerness to moan about how inconveniently encoded that
information is, I forgot to point out the (possibly obvious) limitation
that you will still only see the foreign keys that have been declared.
There may well be any number of other foreign keys that are not
identified as such; you just have to divine their existence or ask a
savant.

--
Roy

UK Ingres User Association Conference 2012 will be on Tuesday June 19 2012.
*NOTE THE CHANGED DATE* See www.uk-iua.org.uk

Reply With Quote
  #9  
Old   
Armand Pirvu (gmail)
 
Posts: n/a

Default Re: [Info-Ingres] List foreign keys - 07-29-2011 , 09:02 AM



I would look then at iiconstraints and iiconstraint_indexes catalogs

Hope this helps
A
On Jul 29, 2011, at 8:06 AM, Lee wrote:

Quote:
Thanks, Paul, but I have to use SQL to perform this task -- via the
Perl DBI. So 'HELP' is a syntax error.

On Jul 29, 12:44 pm, "Paul Mason" <Paul.Ma... (AT) ingres (DOT) com> wrote:
HELP CONSTRAINT <table_name> will list the constraints on a table,
including the foreign key ones.

HTH
Paul



-----Original Message-----
From: info-ingres-boun... (AT) kettleriverconsulting (DOT) com [mailto:info-
ingres-boun... (AT) kettleriverconsulting (DOT) com] On Behalf Of Lee
Sent: 29 July 2011 12:01
To: info-ing... (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] List foreign keys

How can I get a list of a table's foreign keys, in Ingres 9.1?

The documentation for 9.1 is no longer on line, and my client
apparently has none, either.

Thanks in anticipation
lee
_______________________________________________
Info-Ingres mailing list
Info-Ing... (AT) kettleriverconsulting (DOT) com

http://ext-cando.kettleriverconsulti...fo/info-ingres

_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://ext-cando.kettleriverconsulti...fo/info-ingres

Reply With Quote
  #10  
Old   
Roy Hann
 
Posts: n/a

Default Re: List foreign keys - 07-29-2011 , 09:45 AM



Ingres Forums wrote:

Quote:
Then you'll have to use system catalogs. Start with these: iiintegrity,
iikey, iiintegrityidx .
iiintegrity is used for constraints created using the deprecated CREATE
INTEGRITY statement (a refugee from QUEL).

However you've mentioned iikeys and motivated me to do some more
digging, and I wonder if this might suit the OP's requirements:

select k.schema_name, k.table_name, k.column_name
from iikeys k join iiconstraints c
on k.constraint_name = c.constraint_name
and k.schema_name = c.schema_name
and k.table_name = c.table_name
where constraint_type = 'R'
and k.table_name = :table_name
order by k.key_position;

In which case I withdraw my earlier grumbles about how it sucks to have
to parse the text_segment. I do apologise.

--
Roy

UK Ingres User Association Conference 2012 will be on Tuesday June 19 2012.
*NOTE THE CHANGED DATE* See www.uk-iua.org.uk

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.