MySQL JPA @Table 注释“目录”和“模式”变量用于什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11184025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the JPA @Table annotation "catalog" and "schema" variables used for?
提问by Sam Levin
Why are these important, what effect do they have on the database at hand?
为什么这些很重要,它们对手头的数据库有什么影响?
Isn't the "schema" already decided at that point, as it exists in the database?
“模式”不是在那个时候就已经决定了,因为它存在于数据库中吗?
What exactly is a "catalog"? What kind of variable/input is the JPA catalog field expecting? Also, same question for the "schema" field.
究竟什么是“目录”?JPA 目录字段需要什么样的变量/输入?另外,“模式”字段的相同问题。
回答by jpkrohling
Catalogs and schemas are "namespaces" that you define on the server side of the database. Some databases contains schemas, some contains catalogs, and some contains both. When logging in with a specific user, some databases defaults the schema/catalog to the user's namespace, causing the table to not be visible to other users, thus, causing the need to use a "common" namespace. So, depending on the database you are using to back your data, you might want to ignore those settings.
目录和模式是您在数据库服务器端定义的“命名空间”。有些数据库包含模式,有些包含目录,有些包含两者。使用特定用户登录时,某些数据库将架构/目录默认为用户的命名空间,导致该表对其他用户不可见,从而导致需要使用“公共”命名空间。因此,根据您用于支持数据的数据库,您可能希望忽略这些设置。
For MySQL, you might want to ignore those settings. This is because the "database" part of the JDBC URL (the one after the last slash) points to the database name, which is semantically identical to schema (for MySQL).
对于 MySQL,您可能希望忽略这些设置。这是因为 JDBC URL 的“数据库”部分(最后一个斜杠后面的那个)指向数据库名称,它在语义上与模式相同(对于 MySQL)。