0
I searched the web but I did not find anything specific for time field in mysql, only date and timestamp, I am creating a field "hora_emissao" type "time", because I want to store only the time in this field, the line would be the following:
ADD COLUMN `hora_emissao` time NOT NULL DEFAULT CURRENT_TIME;
But I get the following message:
[Err] 1064 - You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right syntax to use near 'CURRENT_TIME
If we give the command: SELECT CURRENT_TIME we see that it shows the server time, or current_time exists.
What is the correct way to create a time field with default value in mysql?
Note: I can use Trigger or other field type, but the idea is to simplify using the default function and use a same time field, since I only need the time, if there was how to leave default the server time would be great.
You can’t do that
– Roberto de Campos
try to add column
hora_emissao
time NOT NULL DEFAULT CURTIME(); source https://dev.mysql.com/doc/refman/5.7/en/date-and-timefunct-ions.html#function_current-time– Motta
What is the Mysql version?
– rray
Version of Mysql 5.7.9
– Marcelo
Tried to put in parentheses: (CURRENT_TIME)?
– anonimo