Difference between revisions of "UNIQUE Table Constraint"

From Recital Documentation Wiki
Jump to: navigation, search
 
Line 31: Line 31:
 
   (acc_ref char(5) default strzero(seqno(),5),;
 
   (acc_ref char(5) default strzero(seqno(),5),;
 
   acc_name char(20))
 
   acc_name char(20))
 
 
ALTER TABLE newcust;
 
ALTER TABLE newcust;
 
   ADD UNIQUE acc_ref+acc_name TAG RefName
 
   ADD UNIQUE acc_ref+acc_name TAG RefName

Latest revision as of 11:16, 22 December 2009

Purpose

Table constraint to define a candidate index


Syntax

UNIQUE <expr> TAG <cTagName> [COLLATE <cCollateSequence>]

UNIQUE [<cTagName>] (column1[column2,…])


See Also

ALTER TABLE, CONSTRAINTS, CREATE TABLE


Description

A constraint is used to define rules that help to provide data integrity. TABLE constraints apply to table-based operations. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation.

UNIQUE <expr> TAG <cTagName> The UNIQUE table constraint is used to define <expr> as a candidate index for the table. The <expr> can contain any valid index key. A unique tag index is built on the specified <expr>; it is given the name as defined in <cTagName>. A table may have more than one candidate index.

COLLATE <cCollateSequence> The optional COLLATE <cCollateSequence> clause is included for Visual FoxPro language compatibility only.

UNIQUE [<cTagName>] (column1[column2,…]) The UNIQUE table constraint is used to define a unique index key. The index is built on the column or columns specified and given the name as defined in <cTagName>.


Example

CREATE TABLE newcust;
  (acc_ref char(5) default strzero(seqno(),5),;
  acc_name char(20))
ALTER TABLE newcust;
  ADD UNIQUE acc_ref+acc_name TAG RefName
 
CREATE TABLE contact;
  (ContRef char(5), LastName char(25), FirstName char(25),;
  UNIQUE FullName (LastName, FirstName, ContRef))


Products

Recital, Recital Server