You are on page 1of 11

We have "alter table" syntax from Oracle to add data constraints in-place in this form:

alter table

table_name

add constraint

constraint_name;

We can also use "alter table" syntax to enable or disable constraints:

alter table

table_name

ENABLE constraint

constraint_name;

alter table

table_name

DISABLE constraint

constraint_name;

Check Constraint

We have details on the different types of constraints:

alter table
table_name

add constraint

check_constraint_name

CHECK

(check_column_name IN

'check_constraint1_value',

'check_constraint2_value',

'check_constraint3_value',

'check_constraint4_value'

) DISABLE|ENABLE;

Here are some examples of Oracle "alter table" syntax to add foreign key constraints.

alter table

cust_table

add constraint

fk_cust_name FOREIGN KEY (person_name)

references

person_table (person_name)

initially deferred deferrable;

Here is an example of a multiple column foreign key constraint:


alter table

cust_table

add constraint

fk_cust_name FOREIGN KEY (person_name, person_gender)

references

person_table (person_name, person_gender)

initially deferred deferrable;

Here is another example of Oracle "alter table" syntax to drop constraints.

ALTER TABLE

cust_table

drop constraint

fk_cust_table_ref;

Here we use Oracle "alter table" syntax to add a check constraint.

alter table

cust_table

add constraint

check_cust_types

CHECK

(cust_type IN

'yuppie',
'dink',

'guppie'

);

Oracle constraint errors

The following errors are associated with Oracle constraint alter commands:

ORA-02290: check constraint (owner.constraintname) violated

ORA-02291: integrity constraint (owner.constraintname) violated - parent key not found

ORA-02292:violated integrity constraint (owner.constraintname)- child record found


Oracle Tips

Render yourself as an Avatar character

How to overload stored procedures

David Ellison: Heir to the Oracle throne?

Oracle whistleblower asking for $42,000,000 payday

2010 Oracle Offshoring declared a disaster

Oracle performance tuning software


Oracle performance Tuning 10g reference poster
Oracle training in Linux commands

Oracle training Excel

Oracle training & performance tuning books

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals. Feel free to ask questions on our Oracle forum.
Verify experience! Anyone considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on advertisements and self-
proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata? Oracle technology is changing and we strive to update our BC Oracle support information. If
you find an error or have a suggestion for improving our content, we would appreciate your feedback.
Just e-mail: and include the URL for the page.
Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 - 2010 by Burleson Enterprises, Inc.

All rights reserved.

You might also like