Difference between revisions of "UNIQUE Table Constraint"

From Lianjapedia
Jump to: navigation, search
m (1 revision: SQL)
m (Text replace - "Recital" to "Lianja")
Line 41: Line 41:
  
 
==Products==
 
==Products==
Recital, Recital Server
+
Lianja, Lianja Server
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL]]
 
[[Category:SQL]]

Revision as of 01:34, 9 December 2012

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

Lianja, Lianja Server