Subject | Re: [Firebird-Java] Re: How to get list of foreign keys |
---|---|
Author | Stefan Mühlemann |
Post date | 2002-09-03T07:08:44Z |
Hello,
why don't you try
try {
ResultSet rs = getMetaData(con).getImportedKeys(null, null, tableName);
while (rs.next()) {
System.out.println("\tImported key: " + rs.getString("PKTABLE_NAME") +
" / " + rs.getString("PKCOLUMN_NAME") + " --> " +
rs.getString("FKTABLE_NAME") + " / " +
rs.getString("FKCOLUMN_NAME"));
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
where tableName is the name of the table you want to inspect.
This gives you a list of all imported keys of this table.
Greetings
Stefan
armenakgrigoryan wrote:
why don't you try
try {
ResultSet rs = getMetaData(con).getImportedKeys(null, null, tableName);
while (rs.next()) {
System.out.println("\tImported key: " + rs.getString("PKTABLE_NAME") +
" / " + rs.getString("PKCOLUMN_NAME") + " --> " +
rs.getString("FKTABLE_NAME") + " / " +
rs.getString("FKCOLUMN_NAME"));
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
where tableName is the name of the table you want to inspect.
This gives you a list of all imported keys of this table.
Greetings
Stefan
armenakgrigoryan wrote:
>
> Sorry for the confusion. I'm trying to get the list of column names
> that are foreign keys.
>
> --- In Firebird-Java@y..., "armenakgrigoryan" <agrigoryan@c...> wrote:
> > Hello guys,
> >
> > Our company going to use Firebird. Everything seems OK except
> System
> > Tables. I came form Oracle world and there was not any problem to
> get
> > any information about database metadata. In Firebird I'm kind of
> > confusing. Could you please advise me how can I get the list of
> > foreign keys. I tried to use SQL request like :
> >
> > select rc.rdb$constraint_name,
> > rc.rdb$relation_name,
> > rc.rdb$constraint_type,
> > rf.rdb$relation_name
> > from rdb$relation_constraints rc,
> > rdb$relation_fields rf
> > where rc.rdb$constraint_type = "FOREIGN KEY" and
> > rc.rdb$relation_name = rf.rdb$relation_name
> >
> > But the problem is that there is no foreign key describing
> > relationship between these two tables.
> >
> > I would really appreciate your response.
> >
> > Thanks,
> > Armenak Grigoryan
>
>
> To unsubscribe from this group, send an email to:
> Firebird-Java-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/