Previous Topic

Book Contents

Book Index

Next Topic

Oracle - Alternative Methods

If the 'Create Archive Scripts' action cannot be used, the following alternative ways of archive creation exist for Oracle:

Option 1 - Export data structure using SQL Developer

Standard Oracle database administration tool 'SQL Developer' can be used in the following way:

  1. Call command 'Database Export' from the 'Tools' menu in SQL Developer. The export wizard opens.
  2. In the first step of the wizard, make sure to clear check boxes 'Export Data' and 'Show Schema'.
  3. In the second step, clear check boxes 'Indexes' and 'Triggers'. All other check boxes may remain selected.
  4. Proceed through the remaining steps and click 'Finish'. A DDL script gets generated.
  5. Open the DDL script in SQL Developer and remove the section of the script containing foreign key constraints.

    Optionally it is possible to create all objects in a new tablespace. To do so, insert at the beginning of the script:

    CREATE TABLESPACE TSARCHIVE DATAFILE 'TSARCHIVE.ora' SIZE 100M autoextend on;

    and replace TS3TABLES and TS3INDEX in the script with TSARCHIVE.

  6. To create the archive schema, insert at the beggining of the script:

    create user <ARCHIVE> identified by manager;

    grant DBA to <ARCHIVE>;

    alter session set current_schema = <ARCHIVE>;

    Where <ARCHIVE> is the archive schema name. (Replace ARCHIVE with your own schema name as needed.)

  7. Execute the DDL script

    Note: You will get errors/warnings when creating database views because they are created in alphabetical order, but some of them reference other database views which may not have been created yet. The views will be created but will not be compiled, you will need to compile all of them later. You can use the following Console Template to generate the script:

    alter view $VIEWS$ compile;

Option 2 - Generate the DDL using a Valuemation Console template

  1. Using the following Console template, generate the DDL needed to create the archive schema:

    -- $TABLES$

    $TABLE.sql.archive$ TABLESPACE TSARCHIVE;

    -- $VIEWS$

    $TABLE.sql.archive$;

    The generated DDL script will contain the CREATE TABLE and CREATE VIEW statements but will NOT include foreign key constraints, indexes and triggers.

  2. Execute the result directly from Valuemation Console:

    $QUALIFIER=<ARCHIVE>;

    create user $QUALIFIER identified by manager;

    grant DBA to $QUALIFIER;

    CREATE TABLESPACE TSARCHIVE DATAFILE 'TSARCHIVE.ora' SIZE 100M autoextend on;

    <content of the generated DDL>

    Where <ARCHIVE> is the archive schema name. (Replace ARCHIVE with your own schema name as needed.)

Optionally it is possible to create triggers to protect data in the archive:

-- $TABLES$

CREATE OR REPLACE TRIGGER PR_$TABLE$

BEFORE DELETE OR UPDATE ON $TABLE$

FOR EACH ROW

BEGIN

RAISE_APPLICATION_ERROR (-20102, 'Illegal attempt to modifiy or delete data in the archive');

END;

See Also

Other Methods

SQL Server - Alternative Methods

DB2