Uploaded image for project: 'DdlUtils'
  1. DdlUtils
  2. DDLUTILS-180

DropAllTables command

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0
    • 1.1
    • Ant Tasks
    • None
    • JDK 1.6.0_02
      Win XP
      Oracle 10g, SqlServer 2005, Derby

    Description

      Adding a command that allows the DDLToDatabase task to drop all the tables in the specified database by issuing a bunch of drop table commands. This is very handy for us when we want to quickly clean out a database without dropping the entire database itself.

      Example usage:

      <target name="db.clean" description="Drops all tables and constraints in the target DB.">
      <input addproperty="db.clean.confirm" message="Are you sure you wish to drop all tables in this DV_MASTER database: ${db.master.url} (${db.master.user}) and in this DV_REFERENCE database: ${db.reference.url} (${db.reference.user})? " validargs="y,n" />
      <condition property="db.clean.abort">
      <equals arg1="n" arg2="${db.clean.confirm}" />
      </condition>
      <fail if="db.clean.abort">Database clean aborted by user.</fail>
      <db.clean.macro db.user="${db.master.user}" db.password="${db.master.password}" db.type="${db.master.type}" db.driver="${db.master.driver}" db.url="${db.master.url}" db.schema="${db.master.schema}" db.catalog="${db.master.catalog}" />
      <db.clean.macro db.user="${db.reference.user}" db.password="${db.reference.password}" db.type="${db.reference.type}" db.driver="${db.reference.driver}" db.url="${db.reference.url}" db.schema="${db.reference.schema}" db.catalog="${db.reference.catalog}"/>
      </target>

      <macrodef name="db.clean.macro">
      <attribute name="db.user" description="Database User Name" />
      <attribute name="db.password" description="Database Password" />
      <attribute name="db.type" description="Type of Database" />
      <attribute name="db.driver" description="Classname of JDBC Driver" />
      <attribute name="db.url" description="JDBC connection URL" />
      <attribute name="db.schema" description="JDBC schema pattern" />
      <attribute name="db.catalog" description="JDBC catalog pattern" />
      <sequential>
      <taskdef name="ddl_to_db" classpathref="ddlutils.classpath" classname="org.apache.ddlutils.task.DdlToDatabaseTask" />
      <ddl_to_db databaseType="@

      {db.type}

      " validateXml="false" schemaPattern="@

      {db.schema}

      " catalogPattern="@

      {db.catalog}

      ">
      <database url="@

      {db.url}

      " driverClassName="@

      {db.driver}

      " username="@

      {db.user}

      " password="@

      {db.password}

      " />
      <dropAllTables />
      </ddl_to_db>
      </sequential>
      </macrodef>

      Attachments

        1. DdlToDatabaseTask.java
          9 kB
          Guy Davis
        2. DropAllTablesCommand.java
          3 kB
          Guy Davis

        Activity

          People

            tomdz Thomas Dudziak
            guy_davis Guy Davis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: