Use the Data Load Tool's recreate
or
recreateschema
command to drop and recreate all tables in
the database associated with the environment. Use the
recreate
command to import the data after recreating all
tables.
The recreate
and
recreateschema
commands drop all tables defined in the
selected datasource. The process then creates new tables based on the
current model's datasource definitions. This method differs from the
reset
command in that a recreated database will always
contain correctly structured tables for the current model.
Table 1. Differences between recreate,
recreateschema, and reset
commands
Command |
Truncates tables |
Drops tables |
Creates tables |
Inserts data |
recreate |
No |
Yes |
Yes |
Yes |
recreateschema |
No |
Yes |
Yes |
No |
reset |
Yes |
No |
No |
Yes |
To recreate a database:
-
In NexJ Studio, click
the arrow next to the Run Tool button and select
Data Load Tool.
The Data Load Tool opens.
-
In the Model section,
select the model you want to use:
- For the currently loaded model, shown in the label, select
Current.
- For a base model in your Model Library, select
Base Model and select one of the available
models from the drop-down list.
- For a previously published model in your file system, select
Published Model JAR and click the
Browse button to locate the published model. You might
be prompted to specify the directory where the published model's
mixins are located.
-
Select the Test check box if you want to
use a test environment.
-
Specify the server and connections that you want the application
to support when running with this database.
-
In the Server field, specify either
the server or environment file that contains the server
configuration information you want to use when recreating the
database. If you specify an environment file, then it will also
include the connections information.
-
In the Connections field, specify the
connections file that you want to use when recreating the
database. If you previously selected an environment file in the
Server field, then it already has the
connections information, and this field becomes inactive.
Important: You must choose an environment or
connections file that uses IDs with the appropriate permissions to
change the database table structure, such as the db_owner fixed
database role in SQL Server. This is necessary because the
recreate
command and the
recreateschema
command overwrite existing
databases.
Note: If you are using the current model, then the
fields allow you to select from among the environment, server, and
connections files within the model. If you are using a base or
published model, then your choice is limited only to the environment,
server, and connections files contained in your global environment
folder.
-
In the Command field, select
recreateschema
or recreate
.
-
In the Data Source field, select the
desired data source.
Selections are limited to the data source connections
included in the environment or connections files for the
model.
-
Click Run.
-
If using a non-test environment, a dialog opens, asking you to
confirm that you want to overwrite the data. After confirming that it
is acceptable to do so, select the check box and click
OK.
- Optional:
Publish the model from the Model Library. Publishing the new
version before making any other changes creates a reference version
for future upgrades. It also ensures that you have a backup working
model if future changes make the model unusable.