简体   繁体   中英

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

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.

  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.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 technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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