|
| 1 | +-- Create schema v |
| 2 | +create schema v; |
| 3 | +-- Create a table in the v schema |
| 4 | +create table v.sensor_data ( |
| 5 | + time timestamptz not null, |
| 6 | + sensor_id int not null, |
| 7 | + temperature double precision not null, |
| 8 | + humidity double precision not null |
| 9 | +); |
| 10 | +-- Convert the table to a hypertable |
| 11 | +select create_hypertable('v.sensor_data', 'time'); |
| 12 | + create_hypertable |
| 13 | +--------------------- |
| 14 | + (1,v,sensor_data,t) |
| 15 | +(1 row) |
| 16 | + |
| 17 | +-- Insert some data into the hypertable |
| 18 | +insert into v.sensor_data (time, sensor_id, temperature, humidity) |
| 19 | +values |
| 20 | + ('2024-08-09', 1, 22.5, 60.2), |
| 21 | + ('2024-08-08', 1, 23.0, 59.1), |
| 22 | + ('2024-08-07', 2, 21.7, 63.3); |
| 23 | +-- Select data from the hypertable |
| 24 | +select |
| 25 | + * |
| 26 | +from |
| 27 | + v.sensor_data; |
| 28 | + time | sensor_id | temperature | humidity |
| 29 | +------------------------------+-----------+-------------+---------- |
| 30 | + Fri Aug 09 00:00:00 2024 PDT | 1 | 22.5 | 60.2 |
| 31 | + Thu Aug 08 00:00:00 2024 PDT | 1 | 23 | 59.1 |
| 32 | + Wed Aug 07 00:00:00 2024 PDT | 2 | 21.7 | 63.3 |
| 33 | +(3 rows) |
| 34 | + |
| 35 | +-- Drop schema v and all its entities |
| 36 | +drop schema v cascade; |
| 37 | +NOTICE: drop cascades to 3 other objects |
| 38 | +DETAIL: drop cascades to table v.sensor_data |
| 39 | +drop cascades to table _timescaledb_internal._hyper_1_1_chunk |
| 40 | +drop cascades to table _timescaledb_internal._hyper_1_2_chunk |
0 commit comments