Difference between revisions of "CHECKUNIQUE Column Constraint"
From Lianjapedia
Yvonne.milne (Talk | contribs) (Created page with "==Purpose== Column constraint to check whether the value of a column is unique ==Syntax== CHECKUNIQUE ==See Also== ALTER TABLE, CONSTRAINTS, CREATE...") |
Yvonne.milne (Talk | contribs) (→Description) |
||
Line 11: | Line 11: | ||
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. | 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 CHECKUNIQUE column constraint is used to check for column uniqueness when adding a new record or updating an existing record in the GUI. If the column value already exists, an error message is displayed when trying to save the record: Cannot save record as field '< | + | The CHECKUNIQUE column constraint is used to check for column uniqueness when adding a new record or updating an existing record in the GUI. If the column value already exists, an error message is displayed when trying to save the record: Cannot save record as field '<tablename>.<column>' is not unique. |
==Example== | ==Example== |
Latest revision as of 13:10, 18 March 2020
Contents
Purpose
Column constraint to check whether the value of a column is unique
Syntax
CHECKUNIQUE
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 CHECKUNIQUE column constraint is used to check for column uniqueness when adding a new record or updating an existing record in the GUI. If the column value already exists, an error message is displayed when trying to save the record: Cannot save record as field '<tablename>.<column>' is not unique.
Example
ALTER TABLE customers; MODIFY CONSTRAINT customerid SET CHECKUNIQUE