skip to main content
Querying data stores with SQL : Supported SQL and Extensions : Create Table for Salesforce : Constraint Definition
  

Try Now
Constraint Definition

Purpose

Supported only for Salesforce-based data stores. Defines a constraint.

Syntax

[CONSTRAINT [constraint_name]
{foreign_key_constraint}]
where:
constraint_name
is ignored. The driver uses the data store relationship naming convention to generate the constraint name.
foreign_key_constraint
defines a link between related tables. See Foreign Key Clause for syntax.
A column defined as a foreign key in one table references a primary key in the related table. Only values that are valid in the primary key are valid in the foreign key. The following example is valid because the foreign key values of the dept id column in the EMP table match those of the id column in the referenced table DEPT:
Table 194. Constraint Definition
Referenced Table
Main Table
DEPT
EMP
(Foreign Key)
id
name
id
name
dept id
1
Dev
1
Mark
1
2
Finance
1
Jim
3
3
Sales
1
Mike
2
The following example, however, is not valid. The value 4 in the dept id column does not match any value in the referenced id column of the DEPT table.
Table 195. Constraint Definition
Referenced Table
Main Table
DEPT
EMP
(Foreign Key)
id
name
id
name
dept id
1
Dev
1
Mark
1
2
Finance
1
Jim
3
3
Sales
1
Mike
4