| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|||
How to impose a check that a certain field can only contain a certain domain of values?For example consider a situation where you are storing an attribute which consists of a finite number of values such as "AM" or "PM"? How do you ensure that any other values are rejected to the concerned field?
|
|
|||
|
You can use SQL's CHECK Constraints
Consider that the field is called "timeperiod" and the table is called "day"
ALTER TABLE day ADD CHECK (timeperiod IN ('AM', 'PM')); |
![]() |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I ensure that a field in a table must contain values within a specific range? | irfanhab | SQL - Questions and Answers | 1 | 05-24-2006 03:46 AM |