您可以在H2中创建多个目录吗? [英] Can you create multiple catalogs in H2?
问题描述
当您像这样连接到嵌入式本地H2数据库时:
When you connect to an embedded local H2 database like so:
jdbc:h2:./target/data/CATALOGA;
H2使用数据库名称(此处为CATALOGA)作为CATALOG_NAME.通过查询INFORMATION_SCHEMA.CATALOGS表可以看到这一点.
H2 uses the database name (CATALOGA here) as the CATALOG_NAME. This can be seen by querying the INFORMATION_SCHEMA.CATALOGS table.
是否可以有多个目录?
您不能插入INFORMATION_SCHEMA,并且H2不允许CREATE 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
查询直接在其中具有目录/模式,我需要能够在H2上执行它们.
The queries have catalog/schema in them directly and I need to be able to execute them on H2.
推荐答案
对于H2,目录是数据库.在H2中,您可以在一个数据库中创建多个架构,但不能创建多个目录.
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.
这篇关于您可以在H2中创建多个目录吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!