bigdatabase33 opened a new issue #5199:
URL: https://github.com/apache/incubator-doris/issues/5199


   **建立了两个表,一个是MySQL外部表,此表在MySQL中为拉链表**
   `CREATE EXTERNAL TABLE 
`mysql_user_behavior`.`mysql_micro_course_progress_user` (
   
     `id` int(11)  NOT NULL ,
     `member_id` int(11)  NOT NULL,
     `username` varchar(50) DEFAULT NULL,
     `course_id` int(11)  NOT NULL COMMENT '课程ID',
     `content_type` tinyint(2)  NOT NULL COMMENT '1:视频2:实验3:习题4:作业5:实验评分6:实时考试',
     `val` varchar(30) NOT NULL COMMENT '完成比',
     `rate` int(3)  NOT NULL COMMENT '实际占比',
     `sum` float NOT NULL COMMENT '资源总分',
     `c_time` datetime NOT NULL COMMENT '创建日期',
     `u_time` datetime NOT NULL COMMENT '修改日期'
   ) ENGINE=ODBC
   COMMENT "用户课程资源进度表"
   PROPERTIES (
   "enable_odbc_table" = "true",
   "odbc_catalog_resource" = "mysql_odbc",
   "database" = "micro_course",
   "table" = "micro_course_progress_user"
   );`
   **一个是有unique key的普通表,我是根据`u_time`字段做增量导入**
   CREATE TABLE `user_behavior`.`micro_course_progress_user`
   (  
     `member_id` int(11)  NOT NULL,  
     `course_id` int(11)  NOT NULL COMMENT '课程ID',
     `content_type` tinyint(2)  NOT NULL COMMENT '1:视频2:实验3:习题4:作业5:实验评分6:实时考试',
     `username` varchar(50) DEFAULT NULL,
     `id` int(11)  NOT NULL ,
     `val` varchar(30) NOT NULL COMMENT '完成比',
     `rate` int(3)  NOT NULL COMMENT '实际占比',
     `sum` float NOT NULL COMMENT '资源总分',
     `c_time` datetime NOT NULL COMMENT '创建日期',
     `u_time` datetime NOT NULL COMMENT '修改日期'
   )
   ENGINE=olap
   UNIQUE KEY(`member_id`,`course_id`,`content_type`)
   COMMENT "用户课程资源进度表"
   DISTRIBUTED BY HASH(`member_id`) BUCKETS 10
   PROPERTIES ("storage_type"="column");
   **增量导入的语句**
   insert into `user_behavior`.micro_course_progress_user select 
member_id,course_id,content_type,username,id,val,rate,sum,c_time,u_time from 
`mysql_user_behavior`.`mysql_micro_course_progress_user` where `u_time` > 
第一个表中的最后更新时间;
   **当我从外部表导入增量或变量到Doris中的有unique 
key的表时,查了下第二个表的数据量多于第一个表,找了下原因,是因为数据并没有按照unique key新数据覆盖旧数据。**


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to