1. 修改表名
rename table 库名.表名 to 库名.表名;
删除表
drop table 库名.表名;
新增表
create table FaceData(
`ObjID` Int64,
`ShotTime` Int64
)
ENGINE = MergeTree -- 引擎
PARTITION BY toYYYYMMDD(toDate(ShotTime / 1000)) --分区
PRIMARY KEY ObjID --主键
ORDER BY ShotTime --索引
SETTINGS index_granularity = 8192; --索引粒度,默认8192
2. 修改字段的值
update 库名.表名 set 字段名='值' where 字段名 = '值';
3. 修改字段类型
alter table product_detail modify column PlateClass Int32;
4. 添加字段
alter table product_detail add column `remark` String DEFAULT '' COMMENT '备注';
5. 修改字段
alter table product_detail modify column `remark` Nullable(String) DEFAULT NULL COMMENT '备注';
6. 删除字段
alter table product_detail drop column `remark`;
7. 更新数据 -- 不建议使用
alter table <table_name> update col1 = expr1, ... where <filter>
-- 示例:
alter table MotorStatistics update
DrivingTimes = DrivingTimes+1,
ShotTime=#{param.shotTime},
PersonFaceUrl=#{param.personFaceUrl},
DeviceID=#{param.deviceId},
Action_time=#{param.actionTime}
WHERE ID=#{param.id}
clickhouse常用语句
最新推荐文章于 2025-04-27 22:40:12 发布