UNIQUE Table Constraint

From Recital Documentation Wiki
Revision as of 17:05, 8 December 2009 by Helengeorge (Talk | contribs)

Jump to: navigation, search

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

set sql to vfp
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
list structure index
 
set sql to mysql
CREATE TABLE contact (ContRef char(5), LastName char(25), FirstName char(25),
UNIQUE FullName (LastName, FirstName, ContRef));


Products

Recital, Recital Server