SQL
创建表
use database_library_name;
CREATE TABLE `tabel_name` (
`create_time` datetime NOT NULL COMMENT '创建日期',
`city_id` bigint NOT NULL DEFAULT 0 COMMENT '城市ID',
`day` date NOT NULL COMMENT '日期 2022-01-01',
`ride_num` bigint NOT NULL DEFAULT 0 COMMENT '订单数量',
`waiting_time` bigint NOT NULL DEFAULT 0 COMMENT '等待时间(s)',
`work_day` int NOT NULL DEFAULT -1 COMMENT '1-周内, 0-周末',
`extra` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '扩展字段,放json',
PRIMARY KEY (`city_id`, `day`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='tabel_name comment'
插入表
HIVE
数学函数
- 待整理
类型转换
- 进制转换
- conv(bigint/string base, int from_base, int to_base)
- 将base从from_base的进制数转换成to_base的进制数
- select conv(‘1000’, 16, 10)
- 4096
编码
- MD5
- md5(string/binary)
- hive 1.3以上版本,返回md5码
- select md5(‘explore_id’)
- b20493d86cdab6537031ae92f22808a0
建表
CREATE TABLE `library_name.talbe_name`(
columns_1 bigint COMMENT '第1列',
columns_2 string COMMENT '第2列',
columns_3 double COMMENT '第3列'
)
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
INSERT OVERWRITE TABLE `library_name`.`table_name` partition(dt)
select time_str, city_name, count, dt
from `library_name`.`table_name`
DISTRIBUTE BY rand();
https://blog.csdn.net/weixin_48482704/article/details/109628681