CREATE TABLE IF NOT EXISTS ${KEY_SPACE}.${this.name} (
session_id text,
user_id int,
organization_id int,
deviceData map<text,frozen<map<text,text>>>,
userData map<text,frozen<map<text,text>>>,
created_at TIMESTAMP,
updated_at TIMESTAMP,
PRIMARY KEY ((user_id,organization_id),created_at)
) WITH CLUSTERING ORDER BY (created_at DESC);
What do you mean by “unique constraint”? The UNIQUE
from SQL
?
Note that all columns that are part of the primary key (partition or clustering keys) are unique by definition.
The UNIQUE
from SQL
? → yes i want to implement that
i tried this but it’s not working
What do you mean not working? Partition key columns are unique across the entire table, while clustering columns are unique across the partition they are located in.
if i add duplicate data then it will be stored
Yes, the only way to implement what you need in ScyllaDB is to add a check on the client side. This can be potentially prone to races, so you might need to use LWT.
Thanks sir, really appreciated it.
is it possible to give default value to column in scyllaDb
No, all columns default to null (no value).