H2 SCRIPT 命令是否像快照一样工作?

发布于 2024-11-10 02:43:42 字数 341 浏览 4 评论 0原文

H2 数据库有一个名为 SCRIPT 的命令来备份内容和/或结构。它可以在数据库运行时执行。

我的问题是: SCRIPT 是否像快照一样工作?在发出 SCRIPT 命令之前是否只获取语句和数据库内容?或者在执行 SCRIPT 时它是否尝试考虑其他进程执行的附加语句?

编辑

为了澄清这个问题,SCRIPT的使用有两个含糊之处:

  • SCRIPT在数据库运行时执行时是否保证事务安全/一致性?
  • SCRIPT 产生的输出是否比 BACKUP 更小?

我问这个问题是为了知道在执行数据库备份时是否应该中断某些查询。

H2 database has a command called SCRIPT to backup content and/or structure. It can be performed while the database is running.

My question is: Does SCRIPT work like a snapshot? Does it only take statement and database content up until the SCRIPT command is issued? Or does it try to take additional statements performed by other processes into account while SCRIPT is being executed?

EDIT

To clarify the question, there are two ambiguities about the usage of SCRIPT:

  • Does SCRIPT guarantee transactional safety/consistency while performed when database is running?
  • Is SCRIPT producing a smaller output than BACKUP?

I am asking this question to know whether I should interrupt some queries while performing a backup of my database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜柠檬 2024-11-17 02:43:42

SCRIPT 命令在开始时锁定每个表(用于读取)。因此生成的 SQL 脚本在事务上是一致的。请注意,其他操作将被阻止,直到操作完成(即使使用多线程选项)。

SCRIPT 产生的输出是否比 BACKUP 更小?

这取决于数据。通常 SQL 脚本会小一点,但不会太多。使用压缩时它要小得多。该脚本的主要优点是您拥有一个人类可读的备份,该备份与软件没有太大的联系(H2 的文件格式可能会改变,但 SQL 不会)。

The SCRIPT command locks each table (for reading) at the beginning. So the resulting SQL script is transactionally consistent. Please note other operations are blocked until the operation is complete (even when using the multi-threaded option).

Is SCRIPT producing a smaller output than BACKUP?

It depends on the data. Usually the SQL script is a bit smaller, but not much. It is quite a lot smaller when using compression. The main advantage of the script is that you have a human readable backup which is not tied that much to the software (the file format of H2 might change, but SQL will not).

狼亦尘 2024-11-17 02:43:42

备份数据库的推荐方法是创建压缩的 SQL 脚本文件。这可以使用 Script 工具。”不幸的是,在使用数据库时确保事务一致性的唯一方法是使用 SQL 命令 BACKUP,它还会复制事务日志。

"The recommended way to backup a database is to create a compressed SQL script file. This can be done using the Script tool." Unfortunately, the only way to ensure transactional consistency while the database is in use is to use the SQL command BACKUP, which also copies the transaction log.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文