Constraints

    The values of a constrained column must comply with the constraint.

    The primary key constraint combines a unique constraint and a not-null constraint. It also defines the default routing value used for sharding.

    Example:

    Currently primary keys cannot be auto generated and have to be specified if data is inserted, otherwise an error is returned.

    Or using a alternate syntax:

    Note

    Not all column types can be used as PRIMARY KEY.

    For further details see .

    Example:

    Note

    For further details see NOT NULL.

    A check constraint allows you to specify that the values in a certain column must satisfy a . This can be used to ensure data integrity. For example, if you have a table to store metrics from sensors and you want to ensure that negative values are rejected:

    For further details see CHECK.