Home > Back-end >  how can I create a table in Vertica with receiving time?
how can I create a table in Vertica with receiving time?

Time:02-14

I get weather telemetries from Kafka and insert it to Vertica. I want to add to the vertica table a 'receive_time' type timestamp column and 'receive_date' type date column that indicate the exact time a telemetry was been inserted to the table.

this is my creation statement for example:

CREATE TABLE my_scheme.weather
(
    location_id int NOT NULL,
    humidity float,
    current_temp float,
    wind_speed float,
    wind_direction varchar(100),
    feels_like float,
    latitude float,
    longitude float,
    current_condition varchar(100)
);

how to add 'receive_time' and 'receive_date' columns that get the time from the Vertica? it is even possible?

CodePudding user response:

You can use DEFAULT expression to set the default value of a column as sysdate.

CREATE TABLE my_scheme.weather
(
    location_id int NOT NULL,
    humidity float,
    current_temp float,
    wind_speed float,
    wind_direction varchar(100),
    feels_like float,
    latitude float,
    longitude float,
    current_condition varchar(100),
    receive_datetime TIMESTAMP DEFAULT sysdate
);

For further read: https://forum.vertica.com/discussion/240077/default-a-column-s-value

  • Related