Adds a
referential integrity constraint to the metadata of a column. See Adding Join Constraints in the Database Administrator's Guide.
Syntax
[ CONSTRAINT constraint-name ]
{ [ NOT ] NULL
| PRIMARY KEY
| REFERENCES table-name [ ( column-name ) ]
[ DEFAULT constant ]
}
Semantics
CONSTRAINT constraint-name |
optionally assigns a name to the constraint. Vertica recommends that you name all constraints. |
NULL |
(default) specifies that the column is allowed to contain null values. |
NOT NULL |
specifies that the column must receive a value during INSERT and UPDATE operations. If no DEFAULT value is specified and no value is provided, the INSERT or UPDATE statement returns an error because no default value exists. |
PRIMARY KEY |
adds a |
REFERENCES |
adds a referential integrity constraint defining the column as a foreign key. If column is omitted, the default is the primary key of table. |
table-name |
specifies the table to which the REFERENCES constraint applies. |
column-name |
specifies the column to which the REFERENCES constraint applies. If column is omitted, the default is the primary key of table-name. |
DEFAULT constant |
specifies a constant to be used by default in any INSERT operation that does not specify a value for the column. The data type of the constant must match the data type of the column. If no default value is specified, the default is null. |
Notes