Adrian Olosutean
Adrian Olosutean

Reputation: 179

Cassandra Timestamp Default Now

Is it possible to have a timestamp column in a table with the default value of now, such that only the other fields are introduced?

Upvotes: 4

Views: 5364

Answers (1)

Ashraful Islam
Ashraful Islam

Reputation: 12830

No, There is no way to set default value in cassandra.

You must provide value or use toUnixTimestamp(now()) when inserting.

Example :

CREATE TABLE sample_times (
    a int, 
    b timestamp, 
    c timeuuid, 
    d bigint, 
    PRIMARY KEY (a,b,c,d)
);

Example Insert :

INSERT INTO sample_times (a,b,c,d) VALUES (1, toUnixTimestamp(now()), 50554d6e-29bb-11e5-b345-feff819cdc9f, 10);

Upvotes: 6

Related Questions