background image
<< Displaying the Available Objects | Generating a Script for Creating Tables >>
<< Displaying the Available Objects | Generating a Script for Creating Tables >>

Special Considerations for Exporting Sequences

Exporting the Database Objects
7-6 Oracle Database 2 Day Developer's Guide
8.
Click Apply to generate the script.
Special Considerations for Exporting Sequences and Triggers
Sequences and triggers require special consideration when you export them. For
sequences, the DDL generated will start your sequence relative to the current value. If
you have a sequence that is used to populate a primary key and the data for that table
will be loaded, keep the sequence as it is. However, if you will not be loading data,
you might want to edit your script, after creation, to reset the
START WITH
value.
For triggers, if you have a before-insert trigger on a table and plan to load data, you
must examine that trigger and decide if you want the actions specified in the trigger to
occur. For example, primary key values are often populated in triggers, and if you
want to preserve the primary key from the
INSERT
statement, ensure that your trigger
only populates the primary key value if it is null, as in the following example:
IF :new.evaluation_id IS NULL
THEN SELECT evaluations_seq.Nextval
INTO :new.evaluation_id
FROM dual;
END IF;
However, if the trigger is not written as in the preceding example, you must either
rewrite your trigger, or disable the trigger before loading the data and then enable it
after the data load is complete. Also check that the current value of the sequence is
greater than the maximum value in the primary key column.