Search code examples
cassandracql

How does Cassandra CQL add constraints?


I can't seem to create a table like this, whose constraints portion is throwing error.

CREATE TABLE admins (
    id UUID PRIMARY KEY,
    username text,
    password text,
    name text,
    access_level text,
    CONSTRAINT access_types CHECK(access_level) in ('true', 'false')
);

SyntaxException: line 7:28 mismatched input 'CHECK' expecting ')' (...    access_level text,    access_types CONSTRAINT [CHECK]...)

How do I add constraints? I can't seem to find a way to add constraints with cql, which doesn't seem to have documentation for it. If this is not supported, why?


Solution

  • Cassandra doesn't have this kind of constraint. Usually, it's up to your app care about it.