リアルタイムアナリティクスデータウェアハウジングオブザーバビリティAI/MLOSS
ClickHouse は SQL データベースであり、使い慣れたものと同じ種類の SELECT クエリを記述してデータを照会できます。たとえば、次のようになります。
SELECT *
FROM helloworld.my_first_table
ORDER BY timestampレスポンスは見やすいテーブル形式で返されます。
┌─user_id─┬─message────────────────────────────────────────────┬───────────timestamp─┬──metric─┐
│ 102 │ Insert a lot of rows per batch │ 2022-03-21 00:00:00 │ 1.41421 │
│ 102 │ Sort your data based on your commonly-used queries │ 2022-03-22 00:00:00 │ 2.718 │
│ 101 │ Hello, ClickHouse! │ 2022-03-22 14:04:09 │ -1 │
│ 101 │ Granules are the smallest chunks of data read │ 2022-03-22 14:04:14 │ 3.14159 │
└─────────┴────────────────────────────────────────────────────┴─────────────────────┴─────────┘
4 rows in set. Elapsed: 0.008 sec.ClickHouseでサポートされている多数の出力フォーマットのいずれかを指定するには、FORMAT 句を追加します。
SELECT *
FROM helloworld.my_first_table
ORDER BY timestamp
FORMAT TabSeparated上記のクエリでは、出力はタブ区切りで返されます。
Query id: 3604df1c-acfd-4117-9c56-f86c69721121
102 Insert a lot of rows per batch 2022-03-21 00:00:00 1.41421
102 Sort your data based on your commonly-used queries 2022-03-22 00:00:00 2.718
101 Hello, ClickHouse! 2022-03-22 14:04:09 -1
101 Granules are the smallest chunks of data read 2022-03-22 14:04:14 3.14159
4 rows in set. Elapsed: 0.005 sec.