Skip to content

NovaStar Program Reference / Database / nsdbcheck


Overview

The nsdbcheck program checks for and optionally repairs database problems and is typically run during the NovaStar install/update. It is run to ensure that the current operational database matches the expected database schema. This helps to ensure that NovaStar software will work as expected. See the nsdbmaintenance program, which is run automatically to check for existence of database tables, which are added as time passes.

The nsdbcheck program does not migrate old database contents to the current database design - this is accomplished using the database repair scripts that are run when reinstalling/updating NovaStar.

The main uses of this script are as follows:

  • --fix (can be used with --drop) - fix the operational database schema to agree with what is expected for the NovaStar version:
    • define data types
    • define functions
    • define views
    • define trigger functions
    • define year_start in the configuration table
    • update table column definitions
    • update table rules
  • --drop (can be used with --fix) - drop unneeded and unrecognized NovaStar database tables:
    • see the Protecting Local Database Tables section below if local database tables need to be kept
    • drop tables that are not part of the NovaStar database design and are not identified as a local database table
    • drop table columns that are not in the current design
    • drop table rules that are not in the current design
  • --reindex - reindex tables that have indices

Without --fix or --drop, the program checks for problems, prints output listing whether checks pass or fail, and indicates that the program should be run with --fix and --drop parameters to take action.

  • monthly data tables data_YYYY_MM are created for period spanning configuration table year_start to next month (or use --startyear and --yearEnd command parameters to control)

Protecting Local Database Tables

Database tables may be added to the core NovaStar database in order to support specific system tasks. The --drop feature by default will attempt to drop tables that are not part of the NovaStar design. To protect local database tables, create a file named /usr/ns/etc/local/nsdbcheck.conf with a list of table names, one name per line.

Command Line Usage

The command line syntax is:

nsdbcheck [options...]

Optional values are shown in square brackets. Command line parameters are as follows.

nsdbcheck Command Line Parameters

Parameter Description Default
--debug Turn on debug messages.
--drop
The legacy -drop parameter is no longer supported.
Drop:
  • tables that are not part of the NovaStar database design and are not identified as a local database table (see the Protecting Local Database Tables section)
  • table columns that are not in the current design
  • table rules that are not in the current design
This is a destructive action that is typically only used in the installation script.
Check the database but don't drop.
-f
--fix
The legacy -fix parameter is no longer supported.
Fix database to match expected schema:
  • define data types
  • define functions
  • define views
  • define trigger functions
  • define year_start in the configuration table
  • update table column definitions
  • update table rules
This action modifies and adds to the database.
Check the database but don't fix.
--help Print program usage.
-h hostname
--hostname hostname
Host name or IP address. localhost
--keeptmp Do not delete the temporary files created during processing, useful for troubleshooting. Delete temporary files.
--reindex
The legacy -reindex parameter is no longer supported.
Reindex database tables for the period specified by --startyear and --yearEnd. This option can be specified independently or with --fix and/or --drop. Check the database but don't reindex.
--startyear YYYY
The legacy -startyear parameter is no longer supported.
Starting year for data partition tables. The configuration table year_start will be set or updated to the value. 1980
-t tablename
--table tablename
The legacy -table parameter is no longer supported.
Check/fix the specified database table only. Check all databases tables.
-v
--version
Print the program version (NovaStar system version).
--yearEnd
The legacy -yearEnd parameter is no longer supported.
Check data partition tables to end of year. Check data tables up to and including the next month.

Examples

Use the following to check and fix the database including data tables for the default period 1980 through the next month:

nsdbcheck --fix

Use the following to check and fix the database including data tables for the default period 1980 through the next month. Unrecognized tables will also be dropped (this is destructive).

nsdbcheck --fix --drop

Use the following to define monthly data tables for start year 2018 through the next month and set the configuration table year_start property to 2018:

nsdbcheck --startyear 2018 --fix

Use the following to define monthly data tables for start year 2018 through the end of the calendar year and set the configuration table year_start property to 2018:

nsdbcheck --startyear 2018 --fix --yearEnd

Scheduling

The program is normal used during software installation.

NovaStar Administrator Interface

The program is not run from the Administrator.

Troubleshooting

Logging output is printed to stdout and stderr and can be redirected to a file.

Use the --keeptmp command parameter to keep temporary files containing SQL to repair the database.

See Also