关键点:分区、默认排序、使用引擎
CREATE TABLE user_model_gpu_info (
`regdate` Date,
`user_id` String,
`puid` String,
`reg_version` String,
`system` String,
`model` String,
`memory` String COMMENT '内存',
`cpu` String,
`cpucore` String,
`cpufeq` String,
`screen_w` String,
`screen_h` String,
`screen_resolution` String,
`screen_density` String,
`shaderlvl` String,
`graphicdevice_id` String,
`graphicdevice` String,
`graphicmemory` String,
`gpu_frame_count` String COMMENT 'gpu跑分',
`model_level` Int32,
`opengl` String,
`graphics_multi_threaded` String,
`supports_instancing` String,
`max_texture_size` String,
`npot_support` String,
`perform_test` String
) ENGINE = MergeTree() PARTITION BY regdate ORDER BY (user_id, puid) SETTINGS index_granularity = 8192
ALTER TABLE use_skill ADD Column integration_name String
ALTER TABLE lost_dwd_unit_use_skill DROP Column integration_name
TRUNCATE TABLE tablename
ALTER TABLE table_name DELETE where date = '2020-01-08'
select REPLACE('7654,7698,7782,7788', ',' ,'_') from table limit 5
CAST(colmun AS String) 或者 toString()
[mysql]SUBSTRING_INDEX()
SELECT SUBSTRING_INDEX('apple,pear,melon', ',', 1) from DUAL
[clickhouse]splitByString( '.',action)[1] -- 从1开始取值提取分割后的元素
(1)
SELECT date, hour,
if(`Column`='hour_pay_gross',`Value`,0) AS `hour_pay_gross`,
if(`Column`='hour_pay_user',`Value`,0) AS `hour_pay_user``
FROM paid_daily_hour_stats
(2)CASE-WHEN
SELECT
CASE WHEN f5='1' THEN '金币'
WHEN f5='2' THEN '钻石'
END AS currency
FROM log
LIMIT 10