Mac OS 기준
앞으로의 개발인생이 편해지려면 Homebrew를 설치하자.
Homebrew는 Apple에서 제공하지 않는 유용한 패키지 관리자를 편리하게 설치할 수 있게 해준다. 프론트를 해보았다면 알겠지만 NPM과 비슷하다고 보면된다.
/bin/bash -c "$(curl -fsSL [<https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>](<https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>))"
brew install --cask clickhouse
System Setting → Privacy & Security → clickhouse-macos-aarch64 → Allow Anyway
xattr -d com.apple.quarantine /opt/homebrew/bin/clickhouse
# 데이터베이스 생성
CREATE DATABASE IF NOT EXISTS helloworld
# 테이블 생성
CREATE TABLE helloworld.my_first_table
(
user_id UInt32,
message String,
timestamp DateTime,
metric Float32
)
ENGINE = MergeTree()
PRIMARY KEY (user_id, timestamp)
# 데이터 생성
INSERT INTO helloworld.my_first_table (user_id, message, timestamp, metric) VALUES
(101, 'Hello, ClickHouse!', now(), -1.0),
(102, 'Insert a lot of rows per batch', yesterday(), 1.41421),
(102, 'Sort your data based on queries', today(), 2.718),
(101, 'Granules are the smallest chunks of data read', now() + 5, 3.14159);
# 데이터 조회
SELECT * FROM helloworld.my_first_table;