Reputation: 312
I want to create a table in memsql
with one of the column as datetime
and its value will be current date-time. I tried giving now()
,current_time()
and current_date()
as default value but nothing is working
singlestore> create table y (col2 datetime default now());
ERROR 1067 (42000): Invalid default value for 'col2'
OR
singlestore> create table y (col2 datetime default current_timestamp());
ERROR 1067 (42000): Invalid default value for 'col2'
OR
singlestore> create table y (col2 datetime default current_date());
ERROR 1064 (42000): 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_date())' at line 1
Version Server version: 5.5.58 MemSQL source distribution (compatible; MySQL Enterprise & MySQL Commercial)
Thank you.
Upvotes: 0
Views: 233
Reputation: 739
That is the right syntax. Which version of SinglestoreDB are you using ?
singlestore [test]> create table y (col2 datetime default now());
Query OK, 0 rows affected (1.691 sec)
edit: This requires a I believe at least version 7.0 of SinglestoreDB. Older versions only support default now() on timestamp columns and not datetime.
Upvotes: 1