H2 SCRIPT 命令是否像快照一样工作?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SCRIPT
命令在开始时锁定每个表(用于读取)。因此生成的 SQL 脚本在事务上是一致的。请注意,其他操作将被阻止,直到操作完成(即使使用多线程选项)。这取决于数据。通常 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).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).
备份数据库的推荐方法是创建压缩的 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 commandBACKUP
, which also copies the transaction log.