clickhouse版本升级的语法变动21.8.9.1至23.8.9.1原创
# 1. 版本跨度
版本跨度:21.8.9.1-->23.8.9.1
# 2. 主要变动
# 2.1 函数:formatDateTime(Time, Format)
--版本:21.8.9.1
select formatDateTime(dateTime, '%Y-%m-%h %H:%M:%S')
--版本:23.8.9.1
select formatDateTime(dateTime, '%Y-%m-%h %H:%i:%S')
--老版本中小时可用%M来格式化,新版本中需用%i
1
2
3
4
5
6
2
3
4
5
6
# 2.2 函数:sleep(3), sleepEachRow(3)
--sleep 30s,sleep()仅支持最长3s,所以可以使用sleepEachRow(3)来解决
--版本:21.8.9.1
select sleepEachRow(3) from system.number limit 10
--版本:23.8.9.1
select sleepEachRow(s) from system.number limit num
--新版本要求 s*num<=3。所以ClickHouse的sleep函数无法支持sleep较长时间。
1
2
3
4
5
6
7
2
3
4
5
6
7
# 2.3 写入S3默认不可以覆盖,文件存在直接报错
--版本:21.8.9.1
insert into function s3('http://qianyi-backup-test.cpm/test.csv', 'TSV', 'oaid String')
select 1;
--版本:23.8.9.1
insert into function s3('http://qianyi-backup-test.cpm/test.csv', 'TSV', 'oaid String')
select 1
settings s3_truncate_on_insert=1;
--老版本可直接覆盖写入,新版本文件存在直接报错,可加配置允许覆盖写入。
--官方解释:保证数据安全性,同时避免误操作。
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11