4

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?

Adrian Olosutean
  • 179
  • 1
  • 3
  • 11

1 Answers1

6

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);
Ashraful Islam
  • 12,470
  • 3
  • 32
  • 53