SQL语句整理五-StarRocks

文章目录
        • 查看版本号:
        • SPLIT:
        • [insert 和 update 结合 select:](#insert 和 update 结合 select:)
        • [报错:1064 - StarRocks planner use long time 3000 ms in memo phase:](#报错:1064 - StarRocks planner use long time 3000 ms in memo phase:)
        • 字段增删改:
查看版本号:
复制代码
select current_version();
current_version()|
-----------------+
3.1.13-d9d3ed7   |

current_version()|
-----------------+
3.3.5-6d81f75    |
SPLIT:
复制代码
select SPLIT_PART(cell_array, ',', 1) from t1;
insert 和 update 结合 select:

insert:

复制代码
insert into `heheda_tmp`(message_id,project,file_date,create_time) select message_id,project,file_date,create_time from heheda limit 10;

update:参考:基于StarRocks的MySQL语句排雷秘籍

复制代码
-- MySQL语法
UPDATE table1 t1
JOIN table2 t2 on t1.a1 = t2.b1 
SET t1.a2 = t2.b2;

-- StarRocks语法,注意的是(1)只能用join,(2)要update的字段不能带表的别名,(3)仅StarRocks3.0以后版本可用
UPDATE table1
SET a2 = t2.b2
FROM table2 t2
WHERE table1.a1 = t2.b1;

-- 样例
update student set age=t2.age from (select student_id,sum(age) from teacher where student_id='sfd' and data_time='2024-11-04 12:00' group by student_id) t2 where t2.student_id=student.student_id;
报错:1064 - StarRocks planner use long time 3000 ms in memo phase:

报错信息为:1064 - StarRocks planner use long time 3000 ms in memo phase, This probably because 1. FE Full GC, 2. Hive external table fetch metadata took a long time, 3. The SQL is very complex. You could 1. adjust FE JVM config, 2. try query again, 3. enlarge new_planner_optimize_timeout session variable

复制代码
-- 解决:https://blog.51cto.com/wang/6113290
show variables like '%imeou%'; -- 默认参数:3000ms
set new_planner_optimize_timeout=8000;
字段增删改:
复制代码
-- 增加字段
ALTER table student_test add COLUMN `name` double NULL COMMENT '姓名';

-- 删除字段
ALTER table student_test drop COLUMN `name`;

-- 修改字段
ALTER table student_test RENAME COLUMN `name` TO `student_name`;
-- 注:修改字段 sql 在 3.3.5 版本上可以成功,而在 3.1.13 上失败。可参考下面两张图片。
-- 2024-12 3.1版本目前已经到了支持末期,3.2版本不是长期支持版,3.3版本会在未来至少半年内会作为 StarRocks 的主流打磨版本,加入了非常多的易用性特性,目前小版本已经迭代了8个,稳定性已经过关,是 StarRocks 当前主流推荐的版本。
相关推荐
AAA修煤气灶刘哥4 小时前
后端人速藏!数据库PD建模避坑指南
数据库·后端·mysql
RestCloud8 小时前
揭秘 CDC 技术:让数据库同步快人一步
数据库·api
得物技术11 小时前
MySQL单表为何别超2000万行?揭秘B+树与16KB页的生死博弈|得物技术
数据库·后端·mysql
可涵不会debug15 小时前
【IoTDB】时序数据库选型指南:工业大数据场景下的技术突围
数据库·时序数据库
ByteBlossom15 小时前
MySQL 面试场景题之如何处理 BLOB 和CLOB 数据类型?
数据库·mysql·面试
麦兜*15 小时前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud
Slaughter信仰15 小时前
深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)第十章知识点问答(10题)
java·jvm·数据库
麦兜*15 小时前
MongoDB 在物联网(IoT)中的应用:海量时序数据处理方案
java·数据库·spring boot·物联网·mongodb·spring