Subject Re: [firebird-support] How to obtain the primary key column(s)
Author Martijn Tonies
Hi,

> If i create a table like this:
>
> create table table1 (
> id integer not null primary key,
> column1 varchar(10) );
>
> or like this:
>
> create table table2 (
> id1 integer not null,
> id2 integer not null,
> column1 varchar(10) );
> alter table table2 add primary key (id1, id2);
>
> How can i obtain, based on system tables, the columns used in the
> primary key of both tables? I am using the query below and it works,
> but i am worried if the index used by the primary key will always
> begin with 'RDB$PRIMARY'. I'd like to know if there is a better way
> to do that.

Also take a look at RDB$RELATION_CONSTRAINTS for constraints
of type 'PRIMARY KEY' -> use the index name found in that table.


With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com