简体   繁体   English

如何为 Android Room 数据库指定数据库架构名称

[英]How to specify a database schema name for Android Room database

Is it possible to specify a database schema name when using Room for Android applications?使用 Room for Android 应用程序时是否可以指定数据库架构名称?

I am trying to set some Sqlite PRAGMA values and want to ensure I am only affecting my applications local database and not any others such as the sqlite database associated with Android WorkerManager.我正在尝试设置一些 Sqlite PRAGMA 值,并希望确保我只影响我的应用程序本地数据库,而不影响任何其他数据库,例如与 Android WorkerManager 关联的 sqlite 数据库。

PRAGMA schema.auto_vacuum = 0 | NONE | 1 | FULL | 2 | INCREMENTAL;

By default the schema name is main ie the main database.默认情况下,模式名称是 main,即主数据库。 If not the default or main then the schema must be an ATTACH ed database or temp (for a temporary database).如果不是 default 或 main,则模式必须是ATTACH ed 数据库或 temp(对于临时数据库)。

  • A pragma may have an optional schema-name before the pragma name. pragma 在 pragma 名称之前可能有一个可选的模式名称。 The schema-name is the name of an ATTACH-ed database or "main" or "temp" for the main and the TEMP databases. schema-name 是 ATTACH-ed 数据库的名称或主数据库和 TEMP 数据库的“main”或“temp”。 If the optional schema name is omitted, "main" is assumed.如果省略可选的模式名称,则假定为“main”。 In some pragmas, the schema name is meaningless and is simply ignored.在一些 pragma 中,模式名称是无意义的,只是被忽略了。 In the documentation below, pragmas for which the schema name is meaningful are shown with a "schema."在下面的文档中,架构名称有意义的编译指示用“架构”显示。 prefix.字首。 As per PRAGMA Statements根据PRAGMA Statements

If you aren't ATTACH ing a database then there is no need for the schema.如果您不是ATTACH数据库,则不需要架构。

ie PRAGMA is only relevant/affects the database or an ATTACH ed database, if the schema is provided and is not main.即 PRAGMA 仅相关/影响数据库或ATTACH ed 数据库,如果提供了模式并且不是主要的。 It will not affect other databases, so other databases will not be affected.它不会影响其他数据库,所以其他数据库不会受到影响。

You may wish to refer to ATTACH and or您可能希望参考ATTACH和或

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM