首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在memsql中添加日期时间数据类型的默认值

如何在memsql中添加日期时间数据类型的默认值
EN

Stack Overflow用户
提问于 2022-06-23 13:51:33
回答 1查看 78关注 0票数 0

我想在memsql中创建一个表,其中一个列作为datetime,它的值将是当前日期时间。我试过将now()current_time()current_date()作为默认值,但没有任何效果。

代码语言:javascript
复制
singlestore> create table y (col2 datetime default now());
ERROR 1067 (42000): Invalid default value for 'col2'

代码语言:javascript
复制
singlestore> create table y (col2 datetime default current_timestamp());
ERROR 1067 (42000): Invalid default value for 'col2'

代码语言:javascript
复制
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

版本Server version: 5.5.58 MemSQL source distribution (compatible; MySQL Enterprise & MySQL Commercial)

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-06-23 14:11:02

这是正确的语法。您使用的是哪个版本的SinglestoreDB?

代码语言:javascript
复制
singlestore [test]> create table y (col2 datetime default now());
Query OK, 0 rows affected (1.691 sec)

编辑:这至少需要一个7.0版的SinglestoreDB。旧版本只支持时间戳列上的默认now(),而不支持datetime。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72731359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档