Im trying to add a new column to my SQL table i want the data type to be TIME and the default value to be CURRENT_TIME
. This is my query.
ALTER TABLE tuesday_records ADD cur_time TIME DEFAULT CURRENT_TIME
And this is the error message i get.
Error
SQL query:
ALTER TABLE tuesday_records ADD cur_time TIME DEFAULT CURRENT_TIME
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CURRENT_TIME' at line 1
答案 0 :(得分:0)
您可以使用生成的列执行所需的操作:
Row1:Field1 Field2 Field3 Field4
Row2:Field1 Field2 Field3 Field4
也就是说,添加一个时间戳列,然后提取时间。
Here是db <>小提琴。
尽管这回答了您的问题,但是我不确定这是否是解决您整体问题的最佳方法。