探索ClickHouse——同时支持导入导出功能的文件格式

在《探索ClickHouse——安装和测试》中,我们使用clickhouse直接从文件中读取数据。clickhouse支持多种格式文件的导入导出,本节我们对此进行分类介绍。

按常见格式区分

JSON

原始的JSON格式只支持导入,不支持导入。同时支持导入和导出的是其他几种类型:

JSONEachRow

{"uuid_string":"{D22473F5-3802-7B40-E053-6C04A8C0A630}","price_string":"230000","time":"2021-06-09 00:00","postcode":"CO13 0PQ","a":"D","b":"N","c":"F","addr1":"4","addr2":"","street":"BELLAMY CLOSE","locality":"KIRBY CROSS","town":"FRINTON-ON-SEA","district":"TENDRING","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3803-7B40-E053-6C04A8C0A630}","price_string":"700000","time":"2021-06-25 00:00","postcode":"IG10 4BS","a":"T","b":"N","c":"F","addr1":"70","addr2":"","street":"SMARTS LANE","locality":"","town":"LOUGHTON","district":"EPPING FOREST","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3804-7B40-E053-6C04A8C0A630}","price_string":"625000","time":"2021-06-28 00:00","postcode":"EN9 1LH","a":"S","b":"N","c":"F","addr1":"7","addr2":"","street":"THE COBBINS","locality":"","town":"WALTHAM ABBEY","district":"EPPING FOREST","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3805-7B40-E053-6C04A8C0A630}","price_string":"360000","time":"2021-02-17 00:00","postcode":"SS9 3AU","a":"S","b":"N","c":"F","addr1":"117","addr2":"","street":"FLEMMING AVENUE","locality":"","town":"LEIGH-ON-SEA","district":"SOUTHEND-ON-SEA","county":"SOUTHEND-ON-SEA","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3806-7B40-E053-6C04A8C0A630}","price_string":"345000","time":"2021-06-25 00:00","postcode":"SS15 6BG","a":"S","b":"N","c":"F","addr1":"2","addr2":"","street":"BROADWATER GREEN","locality":"LAINDON","town":"BASILDON","district":"BASILDON","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3807-7B40-E053-6C04A8C0A630}","price_string":"220000","time":"2021-08-20 00:00","postcode":"CO7 0HE","a":"S","b":"N","c":"F","addr1":"133","addr2":"","street":"CHAPEL ROAD","locality":"BRIGHTLINGSEA","town":"COLCHESTER","district":"TENDRING","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3808-7B40-E053-6C04A8C0A630}","price_string":"362000","time":"2021-06-29 00:00","postcode":"SS15 4AX","a":"T","b":"N","c":"F","addr1":"32","addr2":"","street":"CROUCH STREET","locality":"","town":"BASILDON","district":"BASILDON","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3809-7B40-E053-6C04A8C0A630}","price_string":"300000","time":"2021-06-25 00:00","postcode":"CM9 6EP","a":"T","b":"N","c":"F","addr1":"58","addr2":"","street":"ORCHARD ROAD","locality":"","town":"MALDON","district":"MALDON","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-380A-7B40-E053-6C04A8C0A630}","price_string":"300000","time":"2021-06-17 00:00","postcode":"SS4 3AR","a":"T","b":"N","c":"F","addr1":"32","addr2":"","street":"ALLERTON CLOSE","locality":"","town":"ROCHFORD","district":"ROCHFORD","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-380B-7B40-E053-6C04A8C0A630}","price_string":"535000","time":"2021-10-22 00:00","postcode":"SS9 1PZ","a":"T","b":"N","c":"F","addr1":"113","addr2":"","street":"LEIGHTON AVENUE","locality":"","town":"LEIGH-ON-SEA","district":"SOUTHEND-ON-SEA","county":"SOUTHEND-ON-SEA","d":"A","e":"A"}

JSONStringsEachRow

{"uuid_string":"{D22473F5-3802-7B40-E053-6C04A8C0A630}","price_string":"230000","time":"2021-06-09 00:00","postcode":"CO13 0PQ","a":"D","b":"N","c":"F","addr1":"4","addr2":"","street":"BELLAMY CLOSE","locality":"KIRBY CROSS","town":"FRINTON-ON-SEA","district":"TENDRING","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3803-7B40-E053-6C04A8C0A630}","price_string":"700000","time":"2021-06-25 00:00","postcode":"IG10 4BS","a":"T","b":"N","c":"F","addr1":"70","addr2":"","street":"SMARTS LANE","locality":"","town":"LOUGHTON","district":"EPPING FOREST","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3804-7B40-E053-6C04A8C0A630}","price_string":"625000","time":"2021-06-28 00:00","postcode":"EN9 1LH","a":"S","b":"N","c":"F","addr1":"7","addr2":"","street":"THE COBBINS","locality":"","town":"WALTHAM ABBEY","district":"EPPING FOREST","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3805-7B40-E053-6C04A8C0A630}","price_string":"360000","time":"2021-02-17 00:00","postcode":"SS9 3AU","a":"S","b":"N","c":"F","addr1":"117","addr2":"","street":"FLEMMING AVENUE","locality":"","town":"LEIGH-ON-SEA","district":"SOUTHEND-ON-SEA","county":"SOUTHEND-ON-SEA","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3806-7B40-E053-6C04A8C0A630}","price_string":"345000","time":"2021-06-25 00:00","postcode":"SS15 6BG","a":"S","b":"N","c":"F","addr1":"2","addr2":"","street":"BROADWATER GREEN","locality":"LAINDON","town":"BASILDON","district":"BASILDON","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3807-7B40-E053-6C04A8C0A630}","price_string":"220000","time":"2021-08-20 00:00","postcode":"CO7 0HE","a":"S","b":"N","c":"F","addr1":"133","addr2":"","street":"CHAPEL ROAD","locality":"BRIGHTLINGSEA","town":"COLCHESTER","district":"TENDRING","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3808-7B40-E053-6C04A8C0A630}","price_string":"362000","time":"2021-06-29 00:00","postcode":"SS15 4AX","a":"T","b":"N","c":"F","addr1":"32","addr2":"","street":"CROUCH STREET","locality":"","town":"BASILDON","district":"BASILDON","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-3809-7B40-E053-6C04A8C0A630}","price_string":"300000","time":"2021-06-25 00:00","postcode":"CM9 6EP","a":"T","b":"N","c":"F","addr1":"58","addr2":"","street":"ORCHARD ROAD","locality":"","town":"MALDON","district":"MALDON","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-380A-7B40-E053-6C04A8C0A630}","price_string":"300000","time":"2021-06-17 00:00","postcode":"SS4 3AR","a":"T","b":"N","c":"F","addr1":"32","addr2":"","street":"ALLERTON CLOSE","locality":"","town":"ROCHFORD","district":"ROCHFORD","county":"ESSEX","d":"A","e":"A"}
{"uuid_string":"{D22473F5-380B-7B40-E053-6C04A8C0A630}","price_string":"535000","time":"2021-10-22 00:00","postcode":"SS9 1PZ","a":"T","b":"N","c":"F","addr1":"113","addr2":"","street":"LEIGHTON AVENUE","locality":"","town":"LEIGH-ON-SEA","district":"SOUTHEND-ON-SEA","county":"SOUTHEND-ON-SEA","d":"A","e":"A"}

JSONCompactEachRow

["{D22473F5-3802-7B40-E053-6C04A8C0A630}", "230000", "2021-06-09 00:00", "CO13 0PQ", "D", "N", "F", "4", "", "BELLAMY CLOSE", "KIRBY CROSS", "FRINTON-ON-SEA", "TENDRING", "ESSEX", "A", "A"]
["{D22473F5-3803-7B40-E053-6C04A8C0A630}", "700000", "2021-06-25 00:00", "IG10 4BS", "T", "N", "F", "70", "", "SMARTS LANE", "", "LOUGHTON", "EPPING FOREST", "ESSEX", "A", "A"]
["{D22473F5-3804-7B40-E053-6C04A8C0A630}", "625000", "2021-06-28 00:00", "EN9 1LH", "S", "N", "F", "7", "", "THE COBBINS", "", "WALTHAM ABBEY", "EPPING FOREST", "ESSEX", "A", "A"]
["{D22473F5-3805-7B40-E053-6C04A8C0A630}", "360000", "2021-02-17 00:00", "SS9 3AU", "S", "N", "F", "117", "", "FLEMMING AVENUE", "", "LEIGH-ON-SEA", "SOUTHEND-ON-SEA", "SOUTHEND-ON-SEA", "A", "A"]
["{D22473F5-3806-7B40-E053-6C04A8C0A630}", "345000", "2021-06-25 00:00", "SS15 6BG", "S", "N", "F", "2", "", "BROADWATER GREEN", "LAINDON", "BASILDON", "BASILDON", "ESSEX", "A", "A"]
["{D22473F5-3807-7B40-E053-6C04A8C0A630}", "220000", "2021-08-20 00:00", "CO7 0HE", "S", "N", "F", "133", "", "CHAPEL ROAD", "BRIGHTLINGSEA", "COLCHESTER", "TENDRING", "ESSEX", "A", "A"]
["{D22473F5-3808-7B40-E053-6C04A8C0A630}", "362000", "2021-06-29 00:00", "SS15 4AX", "T", "N", "F", "32", "", "CROUCH STREET", "", "BASILDON", "BASILDON", "ESSEX", "A", "A"]
["{D22473F5-3809-7B40-E053-6C04A8C0A630}", "300000", "2021-06-25 00:00", "CM9 6EP", "T", "N", "F", "58", "", "ORCHARD ROAD", "", "MALDON", "MALDON", "ESSEX", "A", "A"]
["{D22473F5-380A-7B40-E053-6C04A8C0A630}", "300000", "2021-06-17 00:00", "SS4 3AR", "T", "N", "F", "32", "", "ALLERTON CLOSE", "", "ROCHFORD", "ROCHFORD", "ESSEX", "A", "A"]
["{D22473F5-380B-7B40-E053-6C04A8C0A630}", "535000", "2021-10-22 00:00", "SS9 1PZ", "T", "N", "F", "113", "", "LEIGHTON AVENUE", "", "LEIGH-ON-SEA", "SOUTHEND-ON-SEA", "SOUTHEND-ON-SEA", "A", "A"]

JSONCompactStringsEachRow

["{D22473F5-3802-7B40-E053-6C04A8C0A630}", "230000", "2021-06-09 00:00", "CO13 0PQ", "D", "N", "F", "4", "", "BELLAMY CLOSE", "KIRBY CROSS", "FRINTON-ON-SEA", "TENDRING", "ESSEX", "A", "A"]
["{D22473F5-3803-7B40-E053-6C04A8C0A630}", "700000", "2021-06-25 00:00", "IG10 4BS", "T", "N", "F", "70", "", "SMARTS LANE", "", "LOUGHTON", "EPPING FOREST", "ESSEX", "A", "A"]
["{D22473F5-3804-7B40-E053-6C04A8C0A630}", "625000", "2021-06-28 00:00", "EN9 1LH", "S", "N", "F", "7", "", "THE COBBINS", "", "WALTHAM ABBEY", "EPPING FOREST", "ESSEX", "A", "A"]
["{D22473F5-3805-7B40-E053-6C04A8C0A630}", "360000", "2021-02-17 00:00", "SS9 3AU", "S", "N", "F", "117", "", "FLEMMING AVENUE", "", "LEIGH-ON-SEA", "SOUTHEND-ON-SEA", "SOUTHEND-ON-SEA", "A", "A"]
["{D22473F5-3806-7B40-E053-6C04A8C0A630}", "345000", "2021-06-25 00:00", "SS15 6BG", "S", "N", "F", "2", "", "BROADWATER GREEN", "LAINDON", "BASILDON", "BASILDON", "ESSEX", "A", "A"]
["{D22473F5-3807-7B40-E053-6C04A8C0A630}", "220000", "2021-08-20 00:00", "CO7 0HE", "S", "N", "F", "133", "", "CHAPEL ROAD", "BRIGHTLINGSEA", "COLCHESTER", "TENDRING", "ESSEX", "A", "A"]
["{D22473F5-3808-7B40-E053-6C04A8C0A630}", "362000", "2021-06-29 00:00", "SS15 4AX", "T", "N", "F", "32", "", "CROUCH STREET", "", "BASILDON", "BASILDON", "ESSEX", "A", "A"]
["{D22473F5-3809-7B40-E053-6C04A8C0A630}", "300000", "2021-06-25 00:00", "CM9 6EP", "T", "N", "F", "58", "", "ORCHARD ROAD", "", "MALDON", "MALDON", "ESSEX", "A", "A"]
["{D22473F5-380A-7B40-E053-6C04A8C0A630}", "300000", "2021-06-17 00:00", "SS4 3AR", "T", "N", "F", "32", "", "ALLERTON CLOSE", "", "ROCHFORD", "ROCHFORD", "ESSEX", "A", "A"]
["{D22473F5-380B-7B40-E053-6C04A8C0A630}", "535000", "2021-10-22 00:00", "SS9 1PZ", "T", "N", "F", "113", "", "LEIGHTON AVENUE", "", "LEIGH-ON-SEA", "SOUTHEND-ON-SEA", "SOUTHEND-ON-SEA", "A", "A"]

按分隔符

TabSeparated

{D22473F5-3802-7B40-E053-6C04A8C0A630}  230000  2021-06-09 00:00        CO13 0PQ        D       N       F       4               BELLAMY CLOSE   KIRBY CROSS     FRINTON-ON-SEA  TENDRING        ESSEX   A       A
{D22473F5-3803-7B40-E053-6C04A8C0A630}  700000  2021-06-25 00:00        IG10 4BS        T       N       F       70              SMARTS LANE             LOUGHTON        EPPING FOREST   ESSEX   A       A
{D22473F5-3804-7B40-E053-6C04A8C0A630}  625000  2021-06-28 00:00        EN9 1LH S       N       F       7               THE COBBINS             WALTHAM ABBEY   EPPING FOREST   ESSEX   A       A
{D22473F5-3805-7B40-E053-6C04A8C0A630}  360000  2021-02-17 00:00        SS9 3AU S       N       F       117             FLEMMING AVENUE         LEIGH-ON-SEA    SOUTHEND-ON-SEA SOUTHEND-ON-SEA A       A
{D22473F5-3806-7B40-E053-6C04A8C0A630}  345000  2021-06-25 00:00        SS15 6BG        S       N       F       2               BROADWATER GREEN        LAINDON BASILDON        BASILDON        ESSEX   A       A
{D22473F5-3807-7B40-E053-6C04A8C0A630}  220000  2021-08-20 00:00        CO7 0HE S       N       F       133             CHAPEL ROAD     BRIGHTLINGSEA   COLCHESTER      TENDRING        ESSEX   A       A
{D22473F5-3808-7B40-E053-6C04A8C0A630}  362000  2021-06-29 00:00        SS15 4AX        T       N       F       32              CROUCH STREET           BASILDON        BASILDON        ESSEX   A       A
{D22473F5-3809-7B40-E053-6C04A8C0A630}  300000  2021-06-25 00:00        CM9 6EP T       N       F       58              ORCHARD ROAD            MALDON  MALDON  ESSEX   A       A
{D22473F5-380A-7B40-E053-6C04A8C0A630}  300000  2021-06-17 00:00        SS4 3AR T       N       F       32              ALLERTON CLOSE          ROCHFORD        ROCHFORD        ESSEX   A       A
{D22473F5-380B-7B40-E053-6C04A8C0A630}  535000  2021-10-22 00:00        SS9 1PZ T       N       F       113             LEIGHTON AVENUE         LEIGH-ON-SEA    SOUTHEND-ON-SEA SOUTHEND-ON-SEA A       A

CSV

"{D22473F5-3802-7B40-E053-6C04A8C0A630}","230000","2021-06-09 00:00","CO13 0PQ","D","N","F","4","","BELLAMY CLOSE","KIRBY CROSS","FRINTON-ON-SEA","TENDRING","ESSEX","A","A"
"{D22473F5-3803-7B40-E053-6C04A8C0A630}","700000","2021-06-25 00:00","IG10 4BS","T","N","F","70","","SMARTS LANE","","LOUGHTON","EPPING FOREST","ESSEX","A","A"
"{D22473F5-3804-7B40-E053-6C04A8C0A630}","625000","2021-06-28 00:00","EN9 1LH","S","N","F","7","","THE COBBINS","","WALTHAM ABBEY","EPPING FOREST","ESSEX","A","A"
"{D22473F5-3805-7B40-E053-6C04A8C0A630}","360000","2021-02-17 00:00","SS9 3AU","S","N","F","117","","FLEMMING AVENUE","","LEIGH-ON-SEA","SOUTHEND-ON-SEA","SOUTHEND-ON-SEA","A","A"
"{D22473F5-3806-7B40-E053-6C04A8C0A630}","345000","2021-06-25 00:00","SS15 6BG","S","N","F","2","","BROADWATER GREEN","LAINDON","BASILDON","BASILDON","ESSEX","A","A"
"{D22473F5-3807-7B40-E053-6C04A8C0A630}","220000","2021-08-20 00:00","CO7 0HE","S","N","F","133","","CHAPEL ROAD","BRIGHTLINGSEA","COLCHESTER","TENDRING","ESSEX","A","A"
"{D22473F5-3808-7B40-E053-6C04A8C0A630}","362000","2021-06-29 00:00","SS15 4AX","T","N","F","32","","CROUCH STREET","","BASILDON","BASILDON","ESSEX","A","A"
"{D22473F5-3809-7B40-E053-6C04A8C0A630}","300000","2021-06-25 00:00","CM9 6EP","T","N","F","58","","ORCHARD ROAD","","MALDON","MALDON","ESSEX","A","A"
"{D22473F5-380A-7B40-E053-6C04A8C0A630}","300000","2021-06-17 00:00","SS4 3AR","T","N","F","32","","ALLERTON CLOSE","","ROCHFORD","ROCHFORD","ESSEX","A","A"
"{D22473F5-380B-7B40-E053-6C04A8C0A630}","535000","2021-10-22 00:00","SS9 1PZ","T","N","F","113","","LEIGHTON AVENUE","","LEIGH-ON-SEA","SOUTHEND-ON-SEA","SOUTHEND-ON-SEA","A","A"

Values

(‘{D22473F5-3802-7B40-E053-6C04A8C0A630}’,‘230000’,‘2021-06-09 00:00’,‘CO13 0PQ’,‘D’,‘N’,‘F’,‘4’,‘’,‘BELLAMY CLOSE’,‘KIRBY CROSS’,‘FRINTON-ON-SEA’,‘TENDRING’,‘ESSEX’,‘A’,‘A’),(‘{D22473F5-3803-7B40-E053-6C04A8C0A630}’,‘700000’,‘2021-06-25 00:00’,‘IG10 4BS’,‘T’,‘N’,‘F’,‘70’,‘’,‘SMARTS LANE’,‘’,‘LOUGHTON’,‘EPPING FOREST’,‘ESSEX’,‘A’,‘A’),(‘{D22473F5-3804-7B40-E053-6C04A8C0A630}’,‘625000’,‘2021-06-28 00:00’,‘EN9 1LH’,‘S’,‘N’,‘F’,‘7’,‘’,‘THE COBBINS’,‘’,‘WALTHAM ABBEY’,‘EPPING FOREST’,‘ESSEX’,‘A’,‘A’),(‘{D22473F5-3805-7B40-E053-6C04A8C0A630}’,‘360000’,‘2021-02-17 00:00’,‘SS9 3AU’,‘S’,‘N’,‘F’,‘117’,‘’,‘FLEMMING AVENUE’,‘’,‘LEIGH-ON-SEA’,‘SOUTHEND-ON-SEA’,‘SOUTHEND-ON-SEA’,‘A’,‘A’),(‘{D22473F5-3806-7B40-E053-6C04A8C0A630}’,‘345000’,‘2021-06-25 00:00’,‘SS15 6BG’,‘S’,‘N’,‘F’,‘2’,‘’,‘BROADWATER GREEN’,‘LAINDON’,‘BASILDON’,‘BASILDON’,‘ESSEX’,‘A’,‘A’),(‘{D22473F5-3807-7B40-E053-6C04A8C0A630}’,‘220000’,‘2021-08-20 00:00’,‘CO7 0HE’,‘S’,‘N’,‘F’,‘133’,‘’,‘CHAPEL ROAD’,‘BRIGHTLINGSEA’,‘COLCHESTER’,‘TENDRING’,‘ESSEX’,‘A’,‘A’),(‘{D22473F5-3808-7B40-E053-6C04A8C0A630}’,‘362000’,‘2021-06-29 00:00’,‘SS15 4AX’,‘T’,‘N’,‘F’,‘32’,‘’,‘CROUCH STREET’,‘’,‘BASILDON’,‘BASILDON’,‘ESSEX’,‘A’,‘A’),(‘{D22473F5-3809-7B40-E053-6C04A8C0A630}’,‘300000’,‘2021-06-25 00:00’,‘CM9 6EP’,‘T’,‘N’,‘F’,‘58’,‘’,‘ORCHARD ROAD’,‘’,‘MALDON’,‘MALDON’,‘ESSEX’,‘A’,‘A’),(‘{D22473F5-380A-7B40-E053-6C04A8C0A630}’,‘300000’,‘2021-06-17 00:00’,‘SS4 3AR’,‘T’,‘N’,‘F’,‘32’,‘’,‘ALLERTON CLOSE’,‘’,‘ROCHFORD’,‘ROCHFORD’,‘ESSEX’,‘A’,‘A’),(‘{D22473F5-380B-7B40-E053-6C04A8C0A630}’,‘535000’,‘2021-10-22 00:00’,‘SS9 1PZ’,‘T’,‘N’,‘F’,‘113’,‘’,‘LEIGHTON AVENUE’,‘’,‘LEIGH-ON-SEA’,‘SOUTHEND-ON-SEA’,‘SOUTHEND-ON-SEA’,‘A’,‘A’)

按携带更多信息

只携带字段名

TabSeparatedWithNames

uuid_string     price_string    time    postcode        a       b       c       addr1   addr2   street  locality        town    district        county  d       e
{D22473F5-3802-7B40-E053-6C04A8C0A630}  230000  2021-06-09 00:00        CO13 0PQ        D       N       F       4               BELLAMY CLOSE   KIRBY CROSS     FRINTON-ON-SEA  TENDRING        ESSEX   A       A
{D22473F5-3803-7B40-E053-6C04A8C0A630}  700000  2021-06-25 00:00        IG10 4BS        T       N       F       70              SMARTS LANE             LOUGHTON        EPPING FOREST   ESSEX   A       A
{D22473F5-3804-7B40-E053-6C04A8C0A630}  625000  2021-06-28 00:00        EN9 1LH S       N       F       7               THE COBBINS             WALTHAM ABBEY   EPPING FOREST   ESSEX   A       A
{D22473F5-3805-7B40-E053-6C04A8C0A630}  360000  2021-02-17 00:00        SS9 3AU S       N       F       117             FLEMMING AVENUE         LEIGH-ON-SEA    SOUTHEND-ON-SEA SOUTHEND-ON-SEA A       A
{D22473F5-3806-7B40-E053-6C04A8C0A630}  345000  2021-06-25 00:00        SS15 6BG        S       N       F       2               BROADWATER GREEN        LAINDON BASILDON        BASILDON        ESSEX   A       A
{D22473F5-3807-7B40-E053-6C04A8C0A630}  220000  2021-08-20 00:00        CO7 0HE S       N       F       133             CHAPEL ROAD     BRIGHTLINGSEA   COLCHESTER      TENDRING        ESSEX   A       A
{D22473F5-3808-7B40-E053-6C04A8C0A630}  362000  2021-06-29 00:00        SS15 4AX        T       N       F       32              CROUCH STREET           BASILDON        BASILDON        ESSEX   A       A
{D22473F5-3809-7B40-E053-6C04A8C0A630}  300000  2021-06-25 00:00        CM9 6EP T       N       F       58              ORCHARD ROAD            MALDON  MALDON  ESSEX   A       A
{D22473F5-380A-7B40-E053-6C04A8C0A630}  300000  2021-06-17 00:00        SS4 3AR T       N       F       32              ALLERTON CLOSE          ROCHFORD        ROCHFORD        ESSEX   A       A
{D22473F5-380B-7B40-E053-6C04A8C0A630}  535000  2021-10-22 00:00        SS9 1PZ T       N       F       113             LEIGHTON AVENUE         LEIGH-ON-SEA    SOUTHEND-ON-SEA SOUTHEND-ON-SEA A       A

CSVWithNames

"uuid_string","price_string","time","postcode","a","b","c","addr1","addr2","street","locality","town","district","county","d","e"
"{D22473F5-3802-7B40-E053-6C04A8C0A630}","230000","2021-06-09 00:00","CO13 0PQ","D","N","F","4","","BELLAMY CLOSE","KIRBY CROSS","FRINTON-ON-SEA","TENDRING","ESSEX","A","A"
"{D22473F5-3803-7B40-E053-6C04A8C0A630}","700000","2021-06-25 00:00","IG10 4BS","T","N","F","70","","SMARTS LANE","","LOUGHTON","EPPING FOREST","ESSEX","A","A"
"{D22473F5-3804-7B40-E053-6C04A8C0A630}","625000","2021-06-28 00:00","EN9 1LH","S","N","F","7","","THE COBBINS","","WALTHAM ABBEY","EPPING FOREST","ESSEX","A","A"
"{D22473F5-3805-7B40-E053-6C04A8C0A630}","360000","2021-02-17 00:00","SS9 3AU","S","N","F","117","","FLEMMING AVENUE","","LEIGH-ON-SEA","SOUTHEND-ON-SEA","SOUTHEND-ON-SEA","A","A"
"{D22473F5-3806-7B40-E053-6C04A8C0A630}","345000","2021-06-25 00:00","SS15 6BG","S","N","F","2","","BROADWATER GREEN","LAINDON","BASILDON","BASILDON","ESSEX","A","A"
"{D22473F5-3807-7B40-E053-6C04A8C0A630}","220000","2021-08-20 00:00","CO7 0HE","S","N","F","133","","CHAPEL ROAD","BRIGHTLINGSEA","COLCHESTER","TENDRING","ESSEX","A","A"
"{D22473F5-3808-7B40-E053-6C04A8C0A630}","362000","2021-06-29 00:00","SS15 4AX","T","N","F","32","","CROUCH STREET","","BASILDON","BASILDON","ESSEX","A","A"
"{D22473F5-3809-7B40-E053-6C04A8C0A630}","300000","2021-06-25 00:00","CM9 6EP","T","N","F","58","","ORCHARD ROAD","","MALDON","MALDON","ESSEX","A","A"
"{D22473F5-380A-7B40-E053-6C04A8C0A630}","300000","2021-06-17 00:00","SS4 3AR","T","N","F","32","","ALLERTON CLOSE","","ROCHFORD","ROCHFORD","ESSEX","A","A"
"{D22473F5-380B-7B40-E053-6C04A8C0A630}","535000","2021-10-22 00:00","SS9 1PZ","T","N","F","113","","LEIGHTON AVENUE","","LEIGH-ON-SEA","SOUTHEND-ON-SEA","SOUTHEND-ON-SEA","A","A"

携带字段名和类型

TabSeparatedWithNamesAndTypes

uuid_string     price_string    time    postcode        a       b       c       addr1   addr2   street  locality        town    district        county  d       e
String  String  String  String  String  String  String  String  String  String  String  String  String  String  String  String
{D22473F5-3802-7B40-E053-6C04A8C0A630}  230000  2021-06-09 00:00        CO13 0PQ        D       N       F       4               BELLAMY CLOSE   KIRBY CROSS     FRINTON-ON-SEA  TENDRING        ESSEX   A       A
{D22473F5-3803-7B40-E053-6C04A8C0A630}  700000  2021-06-25 00:00        IG10 4BS        T       N       F       70              SMARTS LANE             LOUGHTON        EPPING FOREST   ESSEX   A       A
{D22473F5-3804-7B40-E053-6C04A8C0A630}  625000  2021-06-28 00:00        EN9 1LH S       N       F       7               THE COBBINS             WALTHAM ABBEY   EPPING FOREST   ESSEX   A       A
{D22473F5-3805-7B40-E053-6C04A8C0A630}  360000  2021-02-17 00:00        SS9 3AU S       N       F       117             FLEMMING AVENUE         LEIGH-ON-SEA    SOUTHEND-ON-SEA SOUTHEND-ON-SEA A       A
{D22473F5-3806-7B40-E053-6C04A8C0A630}  345000  2021-06-25 00:00        SS15 6BG        S       N       F       2               BROADWATER GREEN        LAINDON BASILDON        BASILDON        ESSEX   A       A
{D22473F5-3807-7B40-E053-6C04A8C0A630}  220000  2021-08-20 00:00        CO7 0HE S       N       F       133             CHAPEL ROAD     BRIGHTLINGSEA   COLCHESTER      TENDRING        ESSEX   A       A
{D22473F5-3808-7B40-E053-6C04A8C0A630}  362000  2021-06-29 00:00        SS15 4AX        T       N       F       32              CROUCH STREET           BASILDON        BASILDON        ESSEX   A       A
{D22473F5-3809-7B40-E053-6C04A8C0A630}  300000  2021-06-25 00:00        CM9 6EP T       N       F       58              ORCHARD ROAD            MALDON  MALDON  ESSEX   A       A
{D22473F5-380A-7B40-E053-6C04A8C0A630}  300000  2021-06-17 00:00        SS4 3AR T       N       F       32              ALLERTON CLOSE          ROCHFORD        ROCHFORD        ESSEX   A       A
{D22473F5-380B-7B40-E053-6C04A8C0A630}  535000  2021-10-22 00:00        SS9 1PZ T       N       F       113             LEIGHTON AVENUE         LEIGH-ON-SEA    SOUTHEND-ON-SEA SOUTHEND-ON-SEA A       A

JSONCompactEachRowWithNamesAndTypes

["uuid_string", "price_string", "time", "postcode", "a", "b", "c", "addr1", "addr2", "street", "locality", "town", "district", "county", "d", "e"]
["String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String"]
["{D22473F5-3802-7B40-E053-6C04A8C0A630}", "230000", "2021-06-09 00:00", "CO13 0PQ", "D", "N", "F", "4", "", "BELLAMY CLOSE", "KIRBY CROSS", "FRINTON-ON-SEA", "TENDRING", "ESSEX", "A", "A"]
["{D22473F5-3803-7B40-E053-6C04A8C0A630}", "700000", "2021-06-25 00:00", "IG10 4BS", "T", "N", "F", "70", "", "SMARTS LANE", "", "LOUGHTON", "EPPING FOREST", "ESSEX", "A", "A"]
["{D22473F5-3804-7B40-E053-6C04A8C0A630}", "625000", "2021-06-28 00:00", "EN9 1LH", "S", "N", "F", "7", "", "THE COBBINS", "", "WALTHAM ABBEY", "EPPING FOREST", "ESSEX", "A", "A"]
["{D22473F5-3805-7B40-E053-6C04A8C0A630}", "360000", "2021-02-17 00:00", "SS9 3AU", "S", "N", "F", "117", "", "FLEMMING AVENUE", "", "LEIGH-ON-SEA", "SOUTHEND-ON-SEA", "SOUTHEND-ON-SEA", "A", "A"]
["{D22473F5-3806-7B40-E053-6C04A8C0A630}", "345000", "2021-06-25 00:00", "SS15 6BG", "S", "N", "F", "2", "", "BROADWATER GREEN", "LAINDON", "BASILDON", "BASILDON", "ESSEX", "A", "A"]
["{D22473F5-3807-7B40-E053-6C04A8C0A630}", "220000", "2021-08-20 00:00", "CO7 0HE", "S", "N", "F", "133", "", "CHAPEL ROAD", "BRIGHTLINGSEA", "COLCHESTER", "TENDRING", "ESSEX", "A", "A"]
["{D22473F5-3808-7B40-E053-6C04A8C0A630}", "362000", "2021-06-29 00:00", "SS15 4AX", "T", "N", "F", "32", "", "CROUCH STREET", "", "BASILDON", "BASILDON", "ESSEX", "A", "A"]
["{D22473F5-3809-7B40-E053-6C04A8C0A630}", "300000", "2021-06-25 00:00", "CM9 6EP", "T", "N", "F", "58", "", "ORCHARD ROAD", "", "MALDON", "MALDON", "ESSEX", "A", "A"]
["{D22473F5-380A-7B40-E053-6C04A8C0A630}", "300000", "2021-06-17 00:00", "SS4 3AR", "T", "N", "F", "32", "", "ALLERTON CLOSE", "", "ROCHFORD", "ROCHFORD", "ESSEX", "A", "A"]
["{D22473F5-380B-7B40-E053-6C04A8C0A630}", "535000", "2021-10-22 00:00", "SS9 1PZ", "T", "N", "F", "113", "", "LEIGHTON AVENUE", "", "LEIGH-ON-SEA", "SOUTHEND-ON-SEA", "SOUTHEND-ON-SEA", "A", "A"]

JSONCompactStringsEachRowWithNamesAndTypes

["uuid_string", "price_string", "time", "postcode", "a", "b", "c", "addr1", "addr2", "street", "locality", "town", "district", "county", "d", "e"]
["String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String"]
["{D22473F5-3802-7B40-E053-6C04A8C0A630}", "230000", "2021-06-09 00:00", "CO13 0PQ", "D", "N", "F", "4", "", "BELLAMY CLOSE", "KIRBY CROSS", "FRINTON-ON-SEA", "TENDRING", "ESSEX", "A", "A"]
["{D22473F5-3803-7B40-E053-6C04A8C0A630}", "700000", "2021-06-25 00:00", "IG10 4BS", "T", "N", "F", "70", "", "SMARTS LANE", "", "LOUGHTON", "EPPING FOREST", "ESSEX", "A", "A"]
["{D22473F5-3804-7B40-E053-6C04A8C0A630}", "625000", "2021-06-28 00:00", "EN9 1LH", "S", "N", "F", "7", "", "THE COBBINS", "", "WALTHAM ABBEY", "EPPING FOREST", "ESSEX", "A", "A"]
["{D22473F5-3805-7B40-E053-6C04A8C0A630}", "360000", "2021-02-17 00:00", "SS9 3AU", "S", "N", "F", "117", "", "FLEMMING AVENUE", "", "LEIGH-ON-SEA", "SOUTHEND-ON-SEA", "SOUTHEND-ON-SEA", "A", "A"]
["{D22473F5-3806-7B40-E053-6C04A8C0A630}", "345000", "2021-06-25 00:00", "SS15 6BG", "S", "N", "F", "2", "", "BROADWATER GREEN", "LAINDON", "BASILDON", "BASILDON", "ESSEX", "A", "A"]
["{D22473F5-3807-7B40-E053-6C04A8C0A630}", "220000", "2021-08-20 00:00", "CO7 0HE", "S", "N", "F", "133", "", "CHAPEL ROAD", "BRIGHTLINGSEA", "COLCHESTER", "TENDRING", "ESSEX", "A", "A"]
["{D22473F5-3808-7B40-E053-6C04A8C0A630}", "362000", "2021-06-29 00:00", "SS15 4AX", "T", "N", "F", "32", "", "CROUCH STREET", "", "BASILDON", "BASILDON", "ESSEX", "A", "A"]
["{D22473F5-3809-7B40-E053-6C04A8C0A630}", "300000", "2021-06-25 00:00", "CM9 6EP", "T", "N", "F", "58", "", "ORCHARD ROAD", "", "MALDON", "MALDON", "ESSEX", "A", "A"]
["{D22473F5-380A-7B40-E053-6C04A8C0A630}", "300000", "2021-06-17 00:00", "SS4 3AR", "T", "N", "F", "32", "", "ALLERTON CLOSE", "", "ROCHFORD", "ROCHFORD", "ESSEX", "A", "A"]
["{D22473F5-380B-7B40-E053-6C04A8C0A630}", "535000", "2021-10-22 00:00", "SS9 1PZ", "T", "N", "F", "113", "", "LEIGHTON AVENUE", "", "LEIGH-ON-SEA", "SOUTHEND-ON-SEA", "SOUTHEND-ON-SEA", "A", "A"]

TSKV

uuid_string={D22473F5-3802-7B40-E053-6C04A8C0A630}      price_string=230000     time=2021-06-09 00:00   postcode=CO13 0PQ       a=D     b=N     c=F     addr1=4 addr2=  street=BELLAMY CLOSE    locality=KIRBY CROSS    town=FRINTON-ON-SEA     district=TENDRING       county=ESSEX    d=A     e=A
uuid_string={D22473F5-3803-7B40-E053-6C04A8C0A630}      price_string=700000     time=2021-06-25 00:00   postcode=IG10 4BS       a=T     b=N     c=F     addr1=70        addr2=  street=SMARTS LANE      locality=       town=LOUGHTON   district=EPPING FOREST  county=ESSEX    d=A     e=A
uuid_string={D22473F5-3804-7B40-E053-6C04A8C0A630}      price_string=625000     time=2021-06-28 00:00   postcode=EN9 1LH        a=S     b=N     c=F     addr1=7 addr2=  street=THE COBBINS      locality=       town=WALTHAM ABBEY      district=EPPING FOREST  county=ESSEX    d=A     e=A
uuid_string={D22473F5-3805-7B40-E053-6C04A8C0A630}      price_string=360000     time=2021-02-17 00:00   postcode=SS9 3AU        a=S     b=N     c=F     addr1=117       addr2=  street=FLEMMING AVENUE  locality=       town=LEIGH-ON-SEA       district=SOUTHEND-ON-SEA        county=SOUTHEND-ON-SEA  d=A     e=A
uuid_string={D22473F5-3806-7B40-E053-6C04A8C0A630}      price_string=345000     time=2021-06-25 00:00   postcode=SS15 6BG       a=S     b=N     c=F     addr1=2 addr2=  street=BROADWATER GREEN locality=LAINDON        town=BASILDON   district=BASILDON       county=ESSEX    d=A     e=A
uuid_string={D22473F5-3807-7B40-E053-6C04A8C0A630}      price_string=220000     time=2021-08-20 00:00   postcode=CO7 0HE        a=S     b=N     c=F     addr1=133       addr2=  street=CHAPEL ROAD      locality=BRIGHTLINGSEA  town=COLCHESTER district=TENDRING       county=ESSEX    d=A     e=A
uuid_string={D22473F5-3808-7B40-E053-6C04A8C0A630}      price_string=362000     time=2021-06-29 00:00   postcode=SS15 4AX       a=T     b=N     c=F     addr1=32        addr2=  street=CROUCH STREET    locality=       town=BASILDON   district=BASILDON       county=ESSEX    d=A     e=A
uuid_string={D22473F5-3809-7B40-E053-6C04A8C0A630}      price_string=300000     time=2021-06-25 00:00   postcode=CM9 6EP        a=T     b=N     c=F     addr1=58        addr2=  street=ORCHARD ROAD     locality=       town=MALDON     district=MALDON county=ESSEX    d=A     e=A
uuid_string={D22473F5-380A-7B40-E053-6C04A8C0A630}      price_string=300000     time=2021-06-17 00:00   postcode=SS4 3AR        a=T     b=N     c=F     addr1=32        addr2=  street=ALLERTON CLOSE   locality=       town=ROCHFORD   district=ROCHFORD       county=ESSEX    d=A     e=A
uuid_string={D22473F5-380B-7B40-E053-6C04A8C0A630}      price_string=535000     time=2021-10-22 00:00   postcode=SS9 1PZ        a=T     b=N     c=F     addr1=113       addr2=  street=LEIGHTON AVENUE  locality=       town=LEIGH-ON-SEA       district=SOUTHEND-ON-SEA        county=SOUTHEND-ON-SEA  d=A     e=A

RowBinaryWithNamesAndTypes

二进制格式,不支持文本查看。

不可读类型

Native

最高性能的格式。通过二进制格式的块进行写入和读取(即它是基于块的,这和后面介绍的RowBinary系列不同)。它主要用于服务器间交互。
在《探索ClickHouse——使用Projection加速查询》一文中,原始数据是CSV格式,大小约4.6G。导入数据库后约308M。这个数据库的内容导出为Native格式的文件,大小只有约168M。

-rw-rw-r-- 1 fangliang fangliang 176572374 Sep 26 09:19 Native.txt

RowBinary

以二进制格式逐行格式化和解析数据。行和值连续列出,没有分隔符。 这种格式比 Native 格式效率低,因为它是基于行的。
导出这个类型的文件,大概和Native类型的差不多大小。

-rw-rw-r-- 1 fangliang fangliang 176568308 Sep 26 10:12 RowBinary.txt

RowBinaryWithNamesAndTypes

添加头部信息的RowBinary。

其他开源项目类型

Protobuf

Protobuf是一个 Protocol Buffers 格式。此格式需要外部格式描述文件(proto文件)。 该描述文件会进行缓存,以备后续查询。 ClickHouse支持 proto2 和 proto3 语法的proto文件,支持重复/可选/必填字段。

Avro

Apache Avro 是在Apache Hadoop项目中开发的面向行的数据序列化框架。

Parquet

Apache Parquet 是Hadoop生态系统中普遍使用的列式存储格式。

Arrow

Apache Arrow是一种用于内存数据库的格式,共有两种模式,文件与流模式。

ArrowStream

ArrowStream对应的是Arrow的流模式,这种格式适用于内存的流式处理。

ORC

Apache ORC 是Hadoop生态系统中普遍存在的列式存储格式。

其他

Compact和非Compact的区别

非Compact是一条完整符合规则的格式,Compact则是将值变成一个数组保存。以JSONCompactEachRowJSONEachRow为例

# JSONCompactEachRow
["{D22473F5-3802-7B40-E053-6C04A8C0A630}", "230000", "2021-06-09 00:00", "CO13 0PQ", "D", "N", "F", "4", "", "BELLAMY CLOSE", "KIRBY CROSS", "FRINTON-ON-SEA", "TENDRING", "ESSEX", "A", "A"]
# JSONEachRow
{"uuid_string":"{D22473F5-3802-7B40-E053-6C04A8C0A630}","price_string":"230000","time":"2021-06-09 00:00","postcode":"CO13 0PQ","a":"D","b":"N","c":"F","addr1":"4","addr2":"","street":"BELLAMY CLOSE","locality":"KIRBY CROSS","town":"FRINTON-ON-SEA","district":"TENDRING","county":"ESSEX","d":"A","e":"A"}

String和非String的区别

String会将JSON对象转变为一个字符串。以JSONStringsEachRow和JSONEachRow为例:

#  JSONCompactEachRow
[42,"hello",[1,"a"]] 
# JSONCompactStringsEachRow
["42","hello","(2,'a')"] 

导出命令

上述格式可以通过修改下面的命令导出,其中–format用于指定格式。

clickhouse-client --query "SELECT * FROM file('pp-2021.csv', 'CSV', 'uuid_string String, price_string String, time String, postcode String, a String, b String, c String, addr1 String, addr2 String, street String, locality String, town String, district String, county String, d String, e String') LIMIT 10;" --format JSONCompactEachRow > JSONCompactEachRow.txt

查考资料

  • https://clickhouse.com/docs/en/sql-reference/formats

你可能感兴趣的:(clickhouse,clickhouse)