简体   繁体   English

备份不包括表的 derby 数据库

[英]Backup a derby database with excluding a table

I need to backup a derby database (both data and schema) to be restored later using Java我需要备份一个 derby 数据库(数据和模式),以便稍后使用 Java 进行恢复

but I need exclude one of the tables that is very big in size, and it's not important in this case to be backed up但我需要排除其中一个非常大的表,在这种情况下备份并不重要

Is there is any way to export a table as a create statement and list of inset statements?有没有办法将表导出为 create 语句和 inset 语句列表?


I found the following ways to backup, but non of them work in my case:我找到了以下备份方法,但在我的情况下它们都不起作用:

  1. SYSCS_UTIL.SYSCS_BACKUP_DATABASE

    This one will include the table that I don't want in include in the backup这将包括我不想包含在备份中的表

    If I can exclude that table, that will be good.如果我可以排除那张桌子,那就太好了。

  2. SYSCS_UTIL.SYSCS_EXPORT_TABLE

    Calling it for each table is fine, but I don't know how to backup/restore the table schema on that point to restore!为每个表调用它很好,但我不知道如何在该点备份/恢复表模式以恢复!

    It generates a comma separated file with the data on that point of time.它会生成一个逗号分隔的文件,其中包含该时间点的数据。

The opposite of the SYSCS_EXPORT_TABLE system procedure is the SYSCS_IMPORT_TABLE procedure: http://db.apache.org/derby/docs/10.15/ref/rrefimportproc.htmlSYSCS_EXPORT_TABLE系统过程相反的是SYSCS_IMPORT_TABLE过程: http://db.apache.org/derby/docs/10.15/ref/rrefimportproc.ZFC535FDC70AD5276

To make a full backup and restore solution out of this, I'd suggest:要从中制作完整的备份和恢复解决方案,我建议:

  1. Collecting all your export commands into a script and treat that script like a real program (put it under source control, test it, get it reviewed by your colleague, etc.)将您所有的导出命令收集到一个脚本中,并将该脚本视为一个真正的程序(将其置于源代码控制之下、对其进行测试、让您的同事对其进行审查等)
  2. Initially, don't try to restore right back into the same database.最初,不要尝试恢复到同一个数据库。 Create a new database, and restore the data into the new database.创建一个新数据库,并将数据恢复到新数据库中。 In particular, this will help with your testing because you can write commands to fetch the data out of both the old and the new databases and compare them.特别是,这将有助于您的测试,因为您可以编写命令从旧数据库和新数据库中获取数据并进行比较。

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

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