-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.sql
More file actions
27 lines (20 loc) · 772 Bytes
/
console.sql
File metadata and controls
27 lines (20 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
CREATE DATABASE "atx-data";
-- Extend the database with TimescaleDB
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
-- We start by creating a regular SQL table
CREATE TABLE nse_data_daily (
timestamp TIMESTAMP NOT NULL,
open DOUBLE PRECISION NOT NULL,
close DOUBLE PRECISION NOT NULL,
high DOUBLE PRECISION NOT NULL,
low DOUBLE PRECISION NOT NULL,
volume DOUBLE PRECISION NOT NULL,
symbol VARCHAR(20) NOT NULL,
created_time TIMESTAMP NOT NULL,
updated_time TIMESTAMP NOT NULL,
CONSTRAINT timestamp_symbol PRIMARY KEY(timestamp, symbol)
);
-- This creates a hypertable that is partitioned by time
-- using the values in the `time` column.
SELECT create_hypertable('nse_data_daily', 'timestamp');
DROP TABLE "nse_data_daily";