NOT NULL specifies a column may not contain values.
Details
-
INSERTorUPDATEstatements containingNULLvalues are rejected. This includesINSERTstatements that do not include values for any columns that do not have a . For example, if the tablefoohas columnsaandb(andbdoes not have aDEFAULT VALUE), when you run the following command:CockroachDB tries to write aNULLvalue into columnb. If that column has theNOT NULLconstraint, theINSERTstatement is rejected. -
To add the
NOT NULLconstraint to an existing table column, use the statement. -
For more information about
NULL, see .
Syntax
You can only apply theNOT NULL constraint to individual columns.
| Parameter | Description |
|---|---|
table_name | The name of the table you’re creating. |
column_name | The name of the constrained column. |
column_type | The constrained column’s . |
column_constraints | Any other column-level you want to apply to this column. |
column_def | Definitions for any other columns in the table. |
table_constraints | Any table-level you want to apply. |

