background image
<< Generating a Script for Creating Tables | Generating a Script for Creating Views >>
<< Generating a Script for Creating Tables | Generating a Script for Creating Views >>

Generating a Script for Creating Objects

Exporting the Database Objects
7-8 Oracle Database 2 Day Developer's Guide
Show Schema
: Uncheck. In this example, if you check this option, it might be
inappropriate because the schema name in your test or production
environment might not be the same as that in your development environment.
Storage
: Uncheck. If you have specified specific storage clauses for your tables
that you want to preserve, check this option; however, if you have not
specified storage clauses or if you have specified storage clauses that are
specific to your development or test environment (that will be different in the
production environment), uncheck this option.
Terminator
: Check. This is necessary because you want to be able run the
resulting script.
Pretty Print
: Check. If you check this option, the output is more readable.
Include BYTE Keyword
: Uncheck, unless you are working with a multibyte
character set, in which case you should check this option.
Add Force to Views
: Uncheck, because views will be added in another script
for this example.
Constraints as Alters
: Check, to have constraints added in separate SQL
statements after each
CREATE TABLE
.
Export Data
: Uncheck, because you will export the data separately for this
example.
Include Drop Statements
: Uncheck. If you want these objects to replace any
existing objects with the same name, you can include this. However, a better
practice is to have a separate drop script that can be run to remove an older
version of your objects before creation. This avoids the chance of accidentally
removing an object you did not intend to drop.
5.
Click the Objects tab.
6.
In the Objects tab:
Select
hr_conn
for the database connection to be used.
For the type of objects to be exported, expand All My Objects. Then expand
Sequences
, and select EVALUATIONS_SEQ. Expand Tables, and select
EVALUATIONS
, PERFORMANCE_PARTS and SCORES. Uncheck the other
object types.
7.
Click Apply to generate the script.
Object definitions are added to the file in alphabetic order by object type. The sequence
will be the first object created, which is good because it is referenced by the trigger on
evaluations
. The table dependencies require that
evaluations
be created first,
then
performance_parts
, and then
scores
. These happen to be in alphabetical
order, so you do not need to make any changes. However, if you did need to make
changes, you could edit the generated script with any text editor or by opening it
within SQL Developer.
Generating a Script for Creating the PL/SQL Objects
Generate a script to create the package (including the function) that you created if you
followed the instructions earlier in this guide.
To generate a script for creating the PL/SQL objects:
1.
From the SQL Developer main menu, select Tools, then Export DDL (and Data).