Difference between revisions of "CHOICES Column Constraint"

From Lianjapedia
Jump to: navigation, search
(Created page with "==Purpose== Column constraint to specify a choice list for a character column ==Syntax== SET CHOICES <expC> ==See Also== ALTER TABLE, CONSTRAINTS, [[...")
 
Line 16: Line 16:
 
<code lang="recital">
 
<code lang="recital">
 
open database southwind
 
open database southwind
 +
// Static choices
 
ALTER TABLE "example" MODIFY CONSTRAINT TITLE SET CHOICES "Mr,Mrs,Ms"
 
ALTER TABLE "example" MODIFY CONSTRAINT TITLE SET CHOICES "Mr,Mrs,Ms"
 +
// Dynamic choices @tablename,expression
 +
ALTER TABLE "orders" MODIFY CONSTRAINT CUSTOMERID SET CHOICES "@customers,customerid"
 +
// Dynamic choices SQL Select
 +
ALTER TABLE "orders" MODIFY CONSTRAINT CUSTOMERID SET CHOICES "select customerid from customers"
 
</code>
 
</code>
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL]]
 
[[Category:SQL]]

Revision as of 11:14, 11 February 2013

Purpose

Column constraint to specify a choice list for a character column

Syntax

SET CHOICES <expC>

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 CHOICES column constraint is used to specify a choice list for a character column.

Example

open database southwind
// Static choices
ALTER TABLE "example" MODIFY CONSTRAINT TITLE SET CHOICES "Mr,Mrs,Ms"
// Dynamic choices @tablename,expression
ALTER TABLE "orders" MODIFY CONSTRAINT CUSTOMERID SET CHOICES "@customers,customerid"
// Dynamic choices SQL Select
ALTER TABLE "orders" MODIFY CONSTRAINT CUSTOMERID SET CHOICES "select customerid from customers"