Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you create multiple catalogs in H2?

Tags:

jdbc

h2

When you connect to an embedded local H2 database like so:

jdbc:h2:./target/data/CATALOGA;

H2 uses the database name (CATALOGA here) as the CATALOG_NAME. This can be seen by querying the INFORMATION_SCHEMA.CATALOGS table.

Is it possible to have more than one catalog?

You cannot insert into the INFORMATION_SCHEMA and H2 does not allow for CREATE CATALOG statements.


Background information is that we have queries that join across catalogs. So something that looks like:

select * from CATALOGA.dbo.example e
    inner join CATALOGB.dbo.example2 e2 on e.fk = e2.fk

The queries have catalog/schema in them directly and I need to be able to execute them on H2.

like image 394
FGreg Avatar asked Oct 20 '22 04:10

FGreg


1 Answers

For H2, a catalog is a database. In H2, you can create multiple schemas within a database, but not multiple catalogs.

Of course you can create multiple databases, but I guess that's not what you want, because databases are independent. You can link a table in another databases using the "create linked table" feature, but the linked table is still in the same schema.

like image 143
Thomas Mueller Avatar answered Oct 24 '22 01:10

Thomas Mueller