You can test with queries such as:

for tables
select count(*) from information_schema.tables where table_name = ?
this will return a one-row, one-column result set. if the table exists, it 
will return 1, otherwise it will return 0

for columns:
select count(*) from information_schema.columns where table_name = ? and 
column_name = ?

I don't know the solution for foreign key constraints off the top of my 
head, but the solution can be found in one of the tables 
in information_schema

On Friday, 22 June 2012 23:07:13 UTC+2, toolforger wrote:
>
> Hi all, 
>
> what's the best practice to test the existence of a 
> - table 
> - field in a table 
> - foreign key constraint? 
>
> Use case: Incremental database schema evolution. 
> I.e. rows in old and new format are in existence at the same time. 
> Which means columns from old and new format coexist; old-format columns 
> will get dropped once the last old-format row is gone. 
> (Yeah, I like doing crazy stuff :-D ) 
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/wseNP_jR4XQJ.
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