一、简介
clickhouse有多种数据的导入导出方式,可以灵活使用,下面对这些方式分别做些介绍,导入导出的写法与格式和格式设置有关。
二、导入
1.从s3导入
-- 建库建表
CREATE DATABASE git;
CREATE TABLE git.commits
(
hash String,
author LowCardinality(String),
time DateTime,
message String,
files_added UInt32,
files_deleted UInt32,
files_renamed UInt32,
files_modified UInt32,
lines_added UInt32,
lines_deleted UInt32,
hunks_added UInt32,
hunks_removed UInt32,
hunks_changed UInt32
) ENGINE = MergeTree ORDER BY time;
-- 导入数据
INSERT INTO git.commits SELECT *
FROM s3('https://datasets-documentation.s3.amazonaws.com/github/commits/clickhouse/commits.tsv.xz', 'TSV', 'hash String,author LowCardinality(String), time DateTime, message String, files_added UInt32, files_deleted UInt32, files_renamed UInt32, files_modified UInt32, lines_added UInt32, lines_deleted UInt32, hunks_added UInt32, hunks_removed UInt32, hunks_changed UInt32')
0 rows in set. Elapsed: 1.826 sec

本文详细介绍了ClickHouse中如何从S3和本地文件导入数据,包括使用CSV、TSV、SQL等多种格式,以及导出数据到S3、本地文件的多种格式,如CSV、SQLInsert和二进制文件。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



