Difference between revisions of "RANGE Column Constraint"
From Lianjapedia
Yvonne.milne (Talk | contribs) m (1 revision: SQL) |
Yvonne.milne (Talk | contribs) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Column constraint to specify minimum and maximum values for a date or numerical column | Column constraint to specify minimum and maximum values for a date or numerical column | ||
− | |||
==Syntax== | ==Syntax== | ||
RANGE <expr1>,<expr2> | RANGE <expr1>,<expr2> | ||
− | |||
==See Also== | ==See Also== | ||
[[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[CREATE TABLE]] | [[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[CREATE TABLE]] | ||
− | |||
==Description== | ==Description== | ||
Line 15: | Line 12: | ||
The RANGE column constraint is used to specify minimum and maximum values for a date or numerical column. The minimum value is specified in <expr1>, the maximum in <expr2>. Attempting to update the column with a value outside this range generates an error. | The RANGE column constraint is used to specify minimum and maximum values for a date or numerical column. The minimum value is specified in <expr1>, the maximum in <expr2>. Attempting to update the column with a value outside this range generates an error. | ||
− | |||
==Example== | ==Example== | ||
Line 24: | Line 20: | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] |
Latest revision as of 11:08, 11 February 2013
Contents
Purpose
Column constraint to specify minimum and maximum values for a date or numerical column
Syntax
RANGE <expr1>,<expr2>
See Also
ALTER TABLE, CONSTRAINTS, CREATE TABLE
Description
A constraint is used to define rules that help to provide data integrity. Column constraints are specific to the column name specified. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation.
The RANGE column constraint is used to specify minimum and maximum values for a date or numerical column. The minimum value is specified in <expr1>, the maximum in <expr2>. Attempting to update the column with a value outside this range generates an error.
Example
CREATE TABLE orderhead; (ord_week INT RANGE 1,52,; ord_date DATE RANGE date(), gomonth(date(),12))