Restructuring a database which already contains data means changing the schema and/or the storage structure.
You can perform actions purely for the purpose of renaming which only affect the schema in a renaming cycle (see chapter "Renaming database objects (BRENAME, BALTER)").
The activities necessary for restructuring can be divided into three categories as follows:
preparatory measures
restructuring process
follow-up activities.
Preparatory measures
Analyzing and modifying the database schema and storage structure
Checking database consistency
Analyzing memory space statistics
If After Image Logging is activated deactivate it using BMEND (see also section "Saving the database")
Either
save the complete database including DBCOM, COSSD and HASHLIB before the restructuring process
or
save HASHLIB, COSSD, DBDIR and DBCOM before the restructuring process
determine which user realms are required in an analysis run with the statements REPORT IS YES and EXECUTION IS NO
save these user realms before the BALTER execution phase
Detailed information on saving is provided in section "Saving the database".
Figure 22: Preparatory measures for restructuring the database
Restructuring process
This is a process that resembles the creation of a database:
BCHANGE prepares the DBDIR to accept a new SIA
New DDL and SSL definitions are then compiled and the new SIA is entered in the DBDIR
Finally, BALTER adapts the data to the modified schema.
The restructuring cycle of BCHANGE/BALTER cannot be combined with the renaming cycle of BRENAME/BALTER. Renaming in a restructuring cycle is interpreted as deleting the old item and inserting the new item. This can result in the loss of data.
Figure 23: Restructuring process
Follow-up activities
After restructuring, the following activities have to be carried out:
Access rights have to be updated if user group names are defined for access rights in the output database.
Subschemas have to modified to the schema.
DB application programs have to be adapted to the new schema.
Sets and hash areas have to be reorganized using BREORG.
It may also be necessary to use the utility routine BMODTT to reassign DB keys that have been released (see "BMODTT" in the "Recovery, Information and Reorganization" manual).
A logging gap occurs because of the restructuring cycle (see the "Database Operation" manual, Media recovery). After the restructuring cycle you must therefore establish a new basis for media recovery by copying the modified files together with the unmodified files. You must then use BMEND to activate After Image Logging again.
Figure 24: Activities after database restructuring