Home » RDBMS Server » Server Administration » CHECK constraint question
CHECK constraint question [message #374204] Wed, 30 May 2001 09:41 Go to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
I'm new to oracle and have a problem with setting up a constraint list. Example I am trying to setup a column in my table called rating, using VARCHAR2 as the type and 4 as the length. The check is for the ratings i.e g, pg, pg13, r, nc17, nr. Any help would be great either by email or post reply. Thanks
Re: CHECK constraint question [message #374207 is a reply to message #374204] Wed, 30 May 2001 10:23 Go to previous messageGo to next message
m
Messages: 15
Registered: April 2001
Junior Member
ALTER TABLE TableName ADD CONSTRAINT
ConstraintName CHECK (Rating IN ('g', 'pg', 'pg13', 'r', 'nc17', 'nr') ) ;
Re: CHECK constraint question [message #374211 is a reply to message #374207] Wed, 30 May 2001 11:18 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
Remember that the check constraint shown assumes that the column is set to NOT NULL. The constraint can be changed to block nulls too, but this is best done by:
alter table TableName modify (Rating not null);
Previous Topic: DELETE Records Based on multiple fields in another table
Next Topic: How to change Time format
Goto Forum:
  


Current Time: Wed Jul 03 18:10:27 CDT 2024