Difference between revisions of "PRIMARY KEY Table Constraint"

From Lianjapedia
Jump to: navigation, search
m (Text replace - "Recital" to "Lianja")
 
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Table constraint to define table's Primary Key
 
Table constraint to define table's Primary Key
 
  
 
==Syntax==
 
==Syntax==
 
PRIMARY KEY <expr> TAG <cTagName> [COLLATE <cCollateSequence>]
 
PRIMARY KEY <expr> TAG <cTagName> [COLLATE <cCollateSequence>]
 
  
 
==See Also==
 
==See Also==
 
[[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[CREATE TABLE]]
 
[[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[CREATE TABLE]]
 
  
 
==Description==
 
==Description==
Line 17: Line 14:
  
 
The optional COLLATE <cCollateSequence> clause is included for Visual FoxPro language compatibility only.
 
The optional COLLATE <cCollateSequence> clause is included for Visual FoxPro language compatibility only.
 
  
 
==Example==
 
==Example==
Line 28: Line 24:
 
   ADD PRIMARY KEY acc_ref+acc_name TAG RefName
 
   ADD PRIMARY KEY acc_ref+acc_name TAG RefName
 
</code>
 
</code>
 
  
 
==Products==
 
==Products==

Latest revision as of 10:22, 11 December 2012

Purpose

Table constraint to define table's Primary Key

Syntax

PRIMARY KEY <expr> TAG <cTagName> [COLLATE <cCollateSequence>]

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.

The PRIMARY KEY table constraint is used to define <expr> as the table's Primary Key. 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>. If a table already has a primary key defined, an error will be returned.

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

Example

CREATE TABLE newcust;
  (acc_ref char(5) default strzero(seqno(),5),;
  acc_name char(20))
 
ALTER TABLE newcust;
  ADD PRIMARY KEY acc_ref+acc_name TAG RefName

Products

Lianja, Lianja Server