CREATE TABLE feature.user_hot_click_list_weekly (
gid BIGINT NOT NULL,
feat_val JSON NOT NULL,
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
date_p INT AS CAST(FROM_UNIXTIME(create_time,“%Y%m%d”) AS SIGNED) NOT NULL,
UNIQUE KEY (gid,date_p)
)
PARTITION BY RANGE ( date_p ) (
PARTITION p20200611 VALUES LESS THAN ( 20200612 ),
PARTITION p20200612 VALUES LESS THAN ( 20200613 ),
PARTITION p20200613 VALUES LESS THAN ( 20200614 ),
PARTITION p20200614 VALUES LESS THAN ( 20200615 ),
PARTITION p20200615 VALUES LESS THAN ( 20200616 ),
PARTITION p20200616 VALUES LESS THAN ( 20200617 ),
PARTITION p20200617 VALUES LESS THAN ( 20200618 )
)
;
麻烦提供一下 TiDB 版本
4.0
±-------------------+
| @@version |
±-------------------+
| 5.7.25-TiDB-v4.0.0 |
±-------------------+
你好
此问题属于 column 中 as 的用法问题,语句在 mysql 和 tidb 中均无法执行,这边进行了修改,在 cast() 添加 括号,可以在测试环境试一下。如果遇到语句在 tidb 中无法执行的情况,可以在 mysql 中进行尝试,否则需要反馈给我们,感谢支持。
CREATE TABLE user_hot_click_list_weekly (
gid BIGINT NOT NULL,
feat_val JSON NOT NULL,
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
date_p INT AS (CAST(FROM_UNIXTIME(create_time,"%Y%m%d") AS SIGNED)) NOT NULL,
UNIQUE KEY (gid,date_p)
)
PARTITION BY RANGE ( date_p ) (
PARTITION p20200611 VALUES LESS THAN ( 20200612 ),
PARTITION p20200612 VALUES LESS THAN ( 20200613 ),
PARTITION p20200613 VALUES LESS THAN ( 20200614 ),
PARTITION p20200614 VALUES LESS THAN ( 20200615 ),
PARTITION p20200615 VALUES LESS THAN ( 20200616 ),
PARTITION p20200616 VALUES LESS THAN ( 20200617 ),
PARTITION p20200617 VALUES LESS THAN ( 20200618 )
);
好的,感谢;这是生成列的知识是吧?
看来还是mysql不熟啊;多谢帮助
类似函数的使用和作为值来使用应该加上括号告诉解析器此为一个整体。在本案例中,cast 函数作为 as 的值,并存在 create table,所以出现了语法上的错误。
嗯嗯,学到
可以请大佬帮看下吗?
关注帖子即可,这边会顺序处理的
此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。