ClickHouse是一个用于联机分析(OLAP)的列式数据库管理系统(DBMS)
官网(https://clickhouse.com/docs/zh)给出的定义,其实没看懂
这里通过Linux系统说明
ClickHouse安装完成后,直接输入这个命令登录进入客户端
clickhouse-client
SHOW DATABASES;
CREATE DATABASE my_test;
USE my_test;
CREATE TABLE gps_data_store
(
lic_num String,
sim_no String,
send_time DateTime64(3, 'Asia/Shanghai'),
trace_type Int8,
altitude Float64,
longitude Float64,
latitude Float64,
alarm_status String,
int_alarm_status Int32,
speed Float64,
direction Int16,
dept_id Int32,
dept_name String,
vehicle_id Int32,
driver_name String,
status String,
mileage Float64,
is_drift Bool,
valid Bool,
vehicle_color Int8,
vehicle_type String,
vt_code String,
video_alarm0x14 String,
video_alarm0x15 String,
video_alarm0x16 String,
video_alarm0x17 String,
month_mileage Float64,
day_mileage Float64,
create_time DateTime64(3, 'Asia/Shanghai'),
is_alarm Bool,
location Point
) ENGINE = MergeTree()
order by (lic_num,send_time);
ALTER TABLE gps_data_store ADD COLUMN is_alarm Bool;
SELECT lic_num,sim_no,send_time,altitude,longitude,latitude,speed FROM gps_data_store WHERE greatCircleDistance(longitude, latitude,108.87316,34.1)<=60;
-- 4个顶点顺时针
SELECT lic_num,sim_no,send_time,altitude,longitude,latitude,speed FROM gps_data_store WHERE pointInPolygon((longitude, latitude), [(108.949000, 34.344761), (108.937863, 34.344761), (108.937863, 34.340604), (108.949000, 34.340604)]);