Question:
I need to understand how to add a NOT NULL constraint statement to
make sure that all rows have valid values. How do you alter a
column value to make it into a not null constraint?
NOT NULL Constraints
NOT NULL constraints are in-line constraints that
indicate that a column can not contain NULL values. The previous example of the
creation of the MY_STATUS table contained two examples of NOT NULL constraints
being defined. For example, the PERSON_ID column is defined as NOT NULL in that
example.
create table
customer
(status char(3)
not null,
val number
not null);
If you need to add a NOT NULL constraint to a table
after the fact, simply use the alter table command as in this example:
ALTER TABLE my_status MODIFY ( person_id NOT NULL);
Also note:
- You can
build
an index on NULL column values in a table.
- When copying
tables with CTAS, beware
that
NULL values many not copy properly.
|
|
Get the Complete
Oracle SQL Tuning Information
The landmark book
"Advanced Oracle
SQL Tuning The Definitive Reference" is
filled with valuable information on Oracle SQL Tuning.
This book includes scripts and tools to hypercharge Oracle 11g
performance and you can
buy it
for 30% off directly from the publisher.
|