备份Derby数据库,不包括一个表。

huangapple 未分类评论52阅读模式
英文:

Backup a derby database with excluding a table

问题

我需要备份一个Derby数据库(包括数据和模式),以便以后使用Java进行恢复,

但我需要排除其中一个非常大的表,在这种情况下不重要,不需要备份

是否有任何方法可以将表导出为创建语句和插入语句列表?


我找到了以下备份方法,但它们在我的情况下都不起作用:

  1. SYSCS_UTIL.SYSCS_BACKUP_DATABASE

这个方法会包括我不想在备份中包含的那个表

如果我能排除掉那个表就好了。

  1. SYSCS_UTIL.SYSCS_EXPORT_TABLE

对每个表调用此方法是可以的,但我不知道如何在这一点上备份/恢复表模式!

它生成一个以逗号分隔的文件,其中包含该时间点的数据。

英文:

I need to backup a derby database (both data and schema) to be restored later using 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?


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.

  1. 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.

答案1

得分: 0

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.html

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.
英文:

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.html

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.

huangapple
  • 本文由 发表于 2020年5月4日 21:59:39
  • 转载请务必保留本文链接:https://java.coder-hub.com/61594028.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定