Quick Start
Get ScramDB running in 2 minutes with Docker.
1. Pull and Run
docker pull scramdb/scramdb:latest
docker run -d \
--name scramdb \
-p 5432:5432 \
--cap-add=IPC_LOCK \
--ulimit memlock=-1:-1 \
scramdb/scramdb:latest
2. Connect
Use psql or any PostgreSQL client:
psql -h localhost -p 5432 scramdb
You should see:
scramdb=#
3. Create a Table
CREATE TABLE sensors (
id BIGINT PRIMARY KEY,
device_id INTEGER NOT NULL,
temperature DOUBLE PRECISION,
humidity DOUBLE PRECISION,
recorded_at TIMESTAMP
);
4. Insert Data
INSERT INTO sensors VALUES
(1, 101, 22.5, 45.0, '2024-03-15 10:00:00'),
(2, 101, 23.1, 44.0, '2024-03-15 10:05:00'),
(3, 102, 19.8, 55.0, '2024-03-15 10:00:00'),
(4, 102, 20.1, 54.0, '2024-03-15 10:05:00'),
(5, 103, 25.3, 38.0, '2024-03-15 10:00:00');
5. Query
-- Basic aggregation
SELECT
device_id,
AVG(temperature) AS avg_temp,
MIN(humidity) AS min_humidity,
COUNT(*) AS readings
FROM sensors
GROUP BY device_id
ORDER BY avg_temp DESC;
-- Window function
SELECT
device_id,
recorded_at,
temperature,
temperature - LAG(temperature) OVER (
PARTITION BY device_id ORDER BY recorded_at
) AS temp_change
FROM sensors;
6. Load CSV Data
COPY sensors FROM '/data/sensors.csv' (FORMAT CSV, HEADER);
What's Next?
- First Queries - More SQL examples with joins and subqueries
- SQL Reference - Full SQL compatibility reference
- Data Types - PostgreSQL type mapping
- Benchmarks - TPC-H SF1 performance results
- Docker Deployment - Production Docker configuration