background image
<< Adding a Primary Key Constraint | Using the Add Foreign Key Window >>
<< Adding a Primary Key Constraint | Using the Add Foreign Key Window >>

Adding a Foreign Key Constraint

Creating and Using Tables
3-10 Oracle Database 2 Day Developer's Guide
5.
In the Confirmation window, click OK.
You have now created a primary key constraint for the
performance_parts
table.
The following SQL statement was added to your table definition:
CONSTRAINT "PERF_PERF_ID_PK" PRIMARY KEY ("PERFORMANCE_ID")
In
Example 3­4
, you will create a primary key constraint on the
evaluations
table
by entering the required information directly in the SQL Statement window.
Example 3­4 Adding a Primary Key Constraint in SQL Script
ALTER TABLE evaluations
ADD CONSTRAINT eval_eval_id_pk PRIMARY KEY (evaluation_id);
The results of the script follow.
ALTER TABLE evaluations succeeded.
You just created a primary key
eval_eval_id_pk
on the
evaluations
table. If you
click the SQL tab, you will see the following SQL statement was added to your table
definition. You may need to click the Refresh icon.
CONSTRAINT "EVAL_EVAL_ID_PK" PRIMARY KEY ("EVALUATION_ID")
To add a foreign key constraint using the SQL Developer interface:
You will add two foreign key constraints to the
scores
table using the SQL Developer
graphical interface. You could also use the Edit Table window, as in the
NOT NULL
constraint, to accomplish this task.
1.
In the Connections navigation hierarchy, the plus sign (+) next to Tables to expand
the list of tables.
2.
Right-click the
scores
table.
3.
Select Constraint, and then select Add Foreign Key.