The schema tool can be used to view the database schema in XML form or match an XML schema to an existing database.
The wsschema tool can reflect on the current database schema, optionally translating it into an XML representation for further manipulation. The schema tool can take an XML schema definition, calculate the differences between the XML and the existing database schema, and apply the necessary changes to make the databases correspond to the XML schema. The XML format used by the schema tool is abstract from the differences in SQL dialects used by different vendors. The tool also automatically adapts its SQL to meet foreign dependencies, thus the schema tool is useful as a general way to manipulate the schemas.
The command syntax is as follows:
wsschema.sh [parameters][arguments]
wsschema.bat [parameters][arguments]
Issue the command from the bin subdirectory of the profile_root directory.
The default is set to false.
When used with the export or reflect actions, the named file is used to write the exported schema XML. If the file names a resource in the class path, data is written to that resource. Use stdout to write to standard output. The default setting is stdout.
Certain OpenJPA components can use such tables and sequences, like the table schema factory. When using other actions, openjpaTables controls if these tables can be dropped. The default setting is false.
The default is true.
The default is true.
The default is true.
The default is true.
The default is true.
The default is true.
Select true to permit writing schema changes or false to prevent writing schema changes. The default is set to true.
This is the equivalent to setting the openjpa.jdbc.Schemas property to run one time.
Add the necessary schema components to the database to match the given XML document without dropping any data:
$ wsschema.sh targetSchema.xml
$ wsschema.bat targetSchema.xml
Repeat the same action as the previous example, this time not changing the database but instead writing any planned changes to a SQL script:
wsschema.sh -f script.sql targetSchema.xml
wsschema.bat -f script.sql targetSchema.xml
Write an SQL script that recreates the current database:
$ wsschema.sh -a createDB -f script.sql
$ wsschema.bat -a createDB -f script.sql
Refresh the schema and delete all the contents of all the tables that OpenJPA knows about:
$ wsschema.bat -a refresh,deleteTableContents
$ wsschema.bat -a refresh,deleteTableContents
Drop the current database:
$ wsschema.sh -a dropDB
$ wsschema.bat -a dropDB
Write an XML representation of the current schema to the file schema.xml:
$ wsschema.sh -a reflect -f schema.xml
$ wsschema.bat -a reflect -f schema.xml
For more information read the JDBC information in the Apache OpenJPA documentation.