- 格式
- TabSeparated
- TSKV
TSKV
| 输入 | 输出 | 别名 |
|---|---|---|
| ✔ | ✔ |
描述
类似于 TabSeparated 格式,但以 name=value 格式输出值。
名称的转义方式与 TabSeparated 格式相同,且 = 符号也会被转义。
SearchPhrase= count()=8267016
SearchPhrase=bathroom interior design count()=2166
SearchPhrase=clickhouse count()=1655
SearchPhrase=2014 spring fashion count()=1549
SearchPhrase=freeform photos count()=1480
SearchPhrase=angelina jolie count()=1245
SearchPhrase=omsk count()=1112
SearchPhrase=photos of dog breeds count()=1091
SearchPhrase=curtain designs count()=1064
SearchPhrase=baku count()=1000
SELECT * FROM t_null FORMAT TSKV
x=1 y=\N
注意
当存在大量列且每列数据量较小时,此格式效率低下,一般没有使用它的理由。
不过,就效率而言,它并不比 JSONEachRow 格式更差。
在解析时,不同列取值的顺序可以是任意的。 允许省略某些值,此时这些值将被视为其默认值。 在这种情况下,默认值为零和空字符串。 不能将本可以在表中指定的复杂值用作默认值。
在解析过程中,允许添加一个额外字段 tskv,该字段不带等号或值。该字段会被忽略。
在导入时,如果将设置 input_format_skip_unknown_fields 设为 1,则具有未知名称的列将被跳过。
NULL 会被格式化为 \N。
示例用法
插入数据
使用以下名为 football.tskv 的 tskv 文件:
date=2022-04-30 season=2021 home_team=Sutton United away_team=Bradford City home_team_goals=1 away_team_goals=4
date=2022-04-30 season=2021 home_team=Swindon Town away_team=Barrow home_team_goals=2 away_team_goals=1
date=2022-04-30 season=2021 home_team=Tranmere Rovers away_team=Oldham Athletic home_team_goals=2 away_team_goals=0
date=2022-05-02 season=2021 home_team=Port Vale away_team=Newport County home_team_goals=1 away_team_goals=2
date=2022-05-02 season=2021 home_team=Salford City away_team=Mansfield Town home_team_goals=2 away_team_goals=2
date=2022-05-07 season=2021 home_team=Barrow away_team=Northampton Town home_team_goals=1 away_team_goals=3
date=2022-05-07 season=2021 home_team=Bradford City away_team=Carlisle United home_team_goals=2 away_team_goals=0
date=2022-05-07 season=2021 home_team=Bristol Rovers away_team=Scunthorpe United home_team_goals=7 away_team_goals=0
date=2022-05-07 season=2021 home_team=Exeter City away_team=Port Vale home_team_goals=0 away_team_goals=1
date=2022-05-07 season=2021 home_team=Harrogate Town A.F.C. away_team=Sutton United home_team_goals=0 away_team_goals=2
date=2022-05-07 season=2021 home_team=Hartlepool United away_team=Colchester United home_team_goals=0 away_team_goals=2
date=2022-05-07 season=2021 home_team=Leyton Orient away_team=Tranmere Rovers home_team_goals=0 away_team_goals=1
date=2022-05-07 season=2021 home_team=Mansfield Town away_team=Forest Green Rovers home_team_goals=2 away_team_goals=2
date=2022-05-07 season=2021 home_team=Newport County away_team=Rochdale home_team_goals=0 away_team_goals=2
date=2022-05-07 season=2021 home_team=Oldham Athletic away_team=Crawley Town home_team_goals=3 away_team_goals=3
date=2022-05-07 season=2021 home_team=Stevenage Borough away_team=Salford City home_team_goals=4 away_team_goals=2
date=2022-05-07 season=2021 home_team=Walsall away_team=Swindon Town home_team_goals=0 away_team_goals=3
插入数据:
INSERT INTO football FROM INFILE 'football.tskv' FORMAT TSKV;
读取数据
以 TSKV 格式读取数据:
SELECT *
FROM football
FORMAT TSKV
输出将采用制表符分隔格式,并包含两行表头:第一行为列名,第二行为列类型:
date=2022-04-30 season=2021 home_team=Sutton United away_team=Bradford City home_team_goals=1 away_team_goals=4
date=2022-04-30 season=2021 home_team=Swindon Town away_team=Barrow home_team_goals=2 away_team_goals=1
date=2022-04-30 season=2021 home_team=Tranmere Rovers away_team=Oldham Athletic home_team_goals=2 away_team_goals=0
date=2022-05-02 season=2021 home_team=Port Vale away_team=Newport County home_team_goals=1 away_team_goals=2
date=2022-05-02 season=2021 home_team=Salford City away_team=Mansfield Town home_team_goals=2 away_team_goals=2
date=2022-05-07 season=2021 home_team=Barrow away_team=Northampton Town home_team_goals=1 away_team_goals=3
date=2022-05-07 season=2021 home_team=Bradford City away_team=Carlisle United home_team_goals=2 away_team_goals=0
date=2022-05-07 season=2021 home_team=Bristol Rovers away_team=Scunthorpe United home_team_goals=7 away_team_goals=0
date=2022-05-07 season=2021 home_team=Exeter City away_team=Port Vale home_team_goals=0 away_team_goals=1
date=2022-05-07 season=2021 home_team=Harrogate Town A.F.C. away_team=Sutton United home_team_goals=0 away_team_goals=2
date=2022-05-07 season=2021 home_team=Hartlepool United away_team=Colchester United home_team_goals=0 away_team_goals=2
date=2022-05-07 season=2021 home_team=Leyton Orient away_team=Tranmere Rovers home_team_goals=0 away_team_goals=1
date=2022-05-07 season=2021 home_team=Mansfield Town away_team=Forest Green Rovers home_team_goals=2 away_team_goals=2
date=2022-05-07 season=2021 home_team=Newport County away_team=Rochdale home_team_goals=0 away_team_goals=2
date=2022-05-07 season=2021 home_team=Oldham Athletic away_team=Crawley Town home_team_goals=3 away_team_goals=3
date=2022-05-07 season=2021 home_team=Stevenage Borough away_team=Salford City home_team_goals=4 away_team_goals=2
date=2022-05-07 season=2021 home_team=Walsall away_team=Swindon Town home_team_goals=0 away_team_goals=3