Thread: How to get a table's constraints

How to get a table's constraints

From
Carlos Correia
Date:
Hi,

Is there any way of obtaining a list of the constraints (table
constraints and column constraints) of a table? I mean, other then the
foreign key's description (getImportedKeys and getExportedKeys)?

Thanks,

carlos
--
MEMÓRIA PERSISTENTE, Lda.
Tel.: 219 291 591
GSM:  967 511 762
e-mail: carlos@m16e.com
URL: http://www.m16e.com



Re: How to get a table's constraints

From
Kris Jurka
Date:

On 5 Feb 2004, Carlos Correia wrote:

> Is there any way of obtaining a list of the constraints (table
> constraints and column constraints) of a table? I mean, other then the
> foreign key's description (getImportedKeys and getExportedKeys)?
>

You get retrive NOT NULL constraints by checking the NULLABLE column in
DatabaseMetaData.getColumns().  If you are referring to check constraints
the only way to retrieve that is by manually querying the system catalogs,
although 7.4 has a view information_schema.check_constraints which makes
this easy.  JDBC doesn't have any concept of theses constraints because
there is no portable way of representing them.

Kris Jurka


Re: How to get a table's constraints

From
Carlos Correia
Date:
A Qui, 2004-02-05 às 14:51, Kris Jurka escreveu:
> On 5 Feb 2004, Carlos Correia wrote:
>
> > Is there any way of obtaining a list of the constraints (table
> > constraints and column constraints) of a table? I mean, other then the
> > foreign key's description (getImportedKeys and getExportedKeys)?
> >
>
> You get retrive NOT NULL constraints by checking the NULLABLE column in
> DatabaseMetaData.getColumns().  If you are referring to check constraints
> the only way to retrieve that is by manually querying the system catalogs,
> although 7.4 has a view information_schema.check_constraints which makes
> this easy.  JDBC doesn't have any concept of theses constraints because
> there is no portable way of representing them.
>
> Kris Jurka
>

thanks, if it's not portable i'll try not to use it by now ...

carlos