Please enable JavaScript to view this site.

R:BASE 11 Beginners Tutorial

Navigation: Lesson 10 - Maintaining a Database

Understanding R:BASE UNLOAD and RUN

Scroll Prev Top Next More

The R:BASE UNLOAD and RUN commands are useful tools for backing up databases and for backing up the database structure elements. The R:BASE UNLOAD command makes an ASCII file of R:BASE commands; it does not compress the data in any way. The UNLOAD command copies your database into a file that has a different format than your database files. This file cannot be used by R:BASE in place of the database files. Before you can use the contents of the backup file, you must return it to the four database files.

 

There are three parts to the R:BASE UNLOAD command: STRUCTURE, DATA, and ALL. The STRUCTURE contains table and column definitions including indexes, view definitions, granted access rights, rules, constraints, auto-number definitions, and comments. The STRUCTURE does not contain the form, report, or label definitions. Those are actually stored as data. The DATA contains the data from the user-defined tables as well as data from some system tables (forms, reports, labels, and layouts). The structure and data of a database are backed up together by using ALL.

 

Between using ALL or using STRUCTURE and DATA separately as a means to back up the database, the preference is entirely up the you. As it is always recommended that the database be checked before it is backed up, either method will work when restoring a database.

 

The only negative aspect to using ALL is that if you ever encounter errors when restoring a database, it is very difficult to edit the file to correct problems as both the structure and data are in one large ASCII file. With ninety-nine percent of the problems with restoring a database involving a problem with re-creating the database structure, it is recommended that a backup of the STRUCTURE and DATA be stored separately. Ideally, the best method would be to create frequent backups using ALL, and less frequent backups of the STRUCTURE and DATA separately. This way, if there is any need for restoring a database, you will have no issues.

 

In addition to backing up structure to one file and data to another file for ease of correcting problems, the structure of a database does not usually change once it is set. Data, obviously, changes on a daily basis. By backing up database elements separately, the backup process is customized to ensure accurate and easily restored backups.

 

The backup process uses three commands:

 

OUTPUT filename

UNLOAD <parameters>

OUTPUT SCREEN

 

The OUTPUT command creates the file to contain the backup data; the UNLOAD command puts the requested data in the file; the second OUTPUT command closes the file. The created file is an ASCII file containing a series of R:BASE commands-the commands that would recreate the database if they were issued at the R> Prompt.

 

The first OUTPUT command can be enhanced with the added ENCRYPT parameter. When issuing the ENCRYPT parameter, you will be immediately prompted for a password. Then, when the file is RUN, or opened with the R:BASE Editor, you will be prompted for the password. The password is protected with a 512-bit encryption algorithm. To use encryption, the same commands above would be used as follows:

 

OUTPUT filename ENCRYPT

UNLOAD <parameters>

OUTPUT SCREEN

 

The file created always begins with a series of SET commands to set the database environment exactly as it was when the UNLOAD command was issued. This ensures that the QUOTE, DELIMIT and NULL settings match those in the commands and data in the backup file. Object names, such as table names, will be enclosed within the IDQUOTES character, the current setting for DELIMIT is used to separate values, text strings are enclosed in the current setting of QUOTES, and the current value of WIDTH affects the width of data lines in the backup file. When backing up DATE data, R:BASE always sets the DATE FORMAT and SEQUENCE to a four-digit year to ensure that the data is restored accurately. The end of the UNLOAD file resets these to the database setting.

 

The following are three tips that will ensure your database is restored from a back up properly:

 

Set the null symbol to -0- (the R:BASE default) before backing up.

Do not set a special character to the same setting as another special character.

For best results backing up, keep all the default settings.

 

To view the current database character settings and operating conditions:

 

Choose Setting: Configurations Settings from the menu bar.

 

Since a backup file is an ASCII file, when using the R:BASE UNLOAD command to backup up your database or parts of your database, view the file with any text editor to become familiar with the format.

 

UNLOAD does not back up computed-column values; the values will be computed when the database is restored. UNLOAD does not change the data or the structure in the original database. Use the RUN command to restore your data. If a UNLOAD command is included in a transaction when transaction processing is on, the backup cannot be rolled back. The UNLOAD command creates a file with a .LOB extension for binary large objects, and a file for the data and/or structure.