Hi,

I'm not sure what is the best solution. I have tested MySQL,
PostgreSQL, HSQLDB, and Derby.

drop table person;
create table person (id int not null);
alter table person add constraint pk_person primary key(id);
@PRIMARY_KEYS null null PERSON;
@PRIMARY_KEYS null null person;

PostgreSQL returns 'pk_person', Derby returns 'PK_PERSON'; HSQLDB and
H2 return the index name; MySQL returns 'PRIMARY'.

May I ask why do you like to get the constraint name?

Regards,
Thomas


On Sun, Dec 21, 2008 at 1:10 PM, Thomas Kellerer
<[email protected]> wrote:
>
> Hi,
>
> if I create the following table:
>
> CREATE TABLE person (id INTEGER not null, firstname VARCHAR(20),
> lastname VARCHAR(20));
> ALTER TABLE person ADD CONSTRAINT pk_person PRIMARY KEY (id);
>
> DatabaseMetaData.getPrimaryKeys() will return the name of the
> underlying index for the column PK_NAME, not the name I supplied in
> ALTER TABLE
>
> In INFORMATION_SCHEMA.CONSTRAINTS.PK_NAME the correct name is stored.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to