Re-creating the schema of a database
You can use dbschema and DB-Access to save the schema from a database and then re-create the schema in another database. A dbschema output file can contain the statements for creating an entire database.
About this task
Procedure
To save a database schema and re-create the database:
- Use dbschema to save the schema to an output file,
such as db.sql:
dbschema -d db > db.sql
You can also use the -ss option to generate server-specific information:
dbschema -d db -ss > db.sql
- Remove the header information about dbschema, if any, from the output file.
- Add a CREATE DATABASE statement at the beginning of the output file or use DB-Access to create a new database.
- Use DB-Access to
re-create the schema in a new database:
dbaccess - db.sql
When you use db.sql to create a database on a different database server, confirm that dbspaces exist.
Results
The databases db and testdb differ in name but have the same schema.