I would like to ask if it's possible to create a MySQL table that auto fills a time column whenever a new row is inserted. I have researched through various websites on TIMESTAMPS and ways to only select time from DATETIME, but to no luck, I can't find what I need. I'm using Workbench.
This is my table query
create table dev_monitor(
device_id varchar(50),
power_coms float,
date DATE,
time TIME);
I used a trigger that auto fills dates.
CREATE TRIGGER task_creation_timestamp BEFORE INSERT ON dev_monitor
FOR EACH ROW
SET NEW.date = NOW();
But now I'm left with the TIME column.
This is the query that I'll be using.
insert into dev_monitor(device_id, power_coms)
values('aircond2', '3.5');
Note that I only want to insert the device id and power consumption, and whenever I insert those 2 data, I'm trying to have the table auto fill the date and time, but in separate columns.