background image
<< Adding Integrity Constraints | Adding a Primary Key Constraint >>
<< Adding Integrity Constraints | Adding a Primary Key Constraint >>

Adding a NOT NULL Constraint in SQL Script

Creating and Using Tables
3-8 Oracle Database 2 Day Developer's Guide
5.
In the Confirmation window, click OK.
You have now created a
NOT NULL
constraint for the
name
column of the
performance_parts
table.
The definition of the
name
column in the
performance_parts
table is changed to
the following; note that the constraint is automatically enabled.
"NAME" VARCHAR2(80) NOT NULL ENABLE
Example 3­3
shows how you can add another
NOT NULL
constraint to the
performance_parts
table by entering the required information directly in the SQL
Statement window.
Example 3­3 Adding a NOT NULL Constraint in SQL Script
ALTER TABLE performance_parts
MODIFY weight NOT NULL;
The results of the script follow.
ALTER TABLE performance_parts succeeded.
You just created a
NOT NULL
constraint for column
weight
of the
performance_
parts
table. If you click the SQL tab, you will see that the definition of the
weight
column changed. You may need to click the Refresh icon.
"WEIGHT" NUMBER NOT NULL ENABLE
To add a unique constraint using the SQL Developer interface:
You will add a unique constraint 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, click 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 Unique.
4.
In the Add Unique window, enter the following information:
Set the constraint name to
SCORES_EVAL_PERF_UNIQUE
.
Set Column 1 to
EVALUATION_ID
.
Set Column 2 to
PERFORMANCE _ID
.
Click Apply.