Removing a database schema

You can create an SQL script to remove (drop) a database schema by using the gen-drop-schema Ant task.

About this task

To remove a database schema, you proceed in two steps:
  1. Create the SQL script that is necessary to remove the database schema.
  2. Run the SQL script that you created.

Procedure

  1. To create the SQL script to delete a database schema, run the gen-drop-schema Ant task with the following parameters:
    -Dserver.url=<server url>
    -DdatasourceName=<data source name>
    -DextensionModel=<model file>
    The description of the database schema to remove.
    [-DdbSchemaName=<database schema name>]
    You can use an optional parameter to specify the database schema name. If you do not specify this parameter, Decision Center uses the database username as the schema name. However, in some databases, users can access several schemas and the default schema is not always named as the user.
    [-DoutputFile=<SQL file>]
    The name of the file that stores the generated SQL script. If you do not specify this parameter, the task creates a file named output.sql in the directory that is defined as basedir in the build.xml file.
    ant gen-drop-schema  -DextensionModel=my_model_file.brmx -DoutputFile=my_sql_file.sql
  2. To use the SQL script that you created, run the execute-schema Ant task with these parameters:
    -Dserver.url=<server url>
    -DdatasourceName=<data source name>
    [-Dfile=<SQL file>]
    The name of the file to run, which corresponds to the script that you created. If you do not specify this parameter, the task attempts to run a file named output.sql in the directory that is defined as basedir in the build.xml file.
    ant execute-schema  -Dfile=my_sql_file.sql

    The task connects to the specified data source from the application server. It reads the model description that is passed in the parameters, and generates the SQL script to remove the existing schema. Because many database tables are linked through foreign keys, these tables must be removed in a specific order and the script generation handles these constraints.

Example

Here is the complete code sample:
ant gen-drop-schema  -DextensionModel=my_model_file.brmx -DoutputFile=my_sql_file.sql
ant execute-schema  -Dfile=my_sql_file.sql