mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-19 12:13:24 +08:00
30 lines
1.1 KiB
SQL
30 lines
1.1 KiB
SQL
\ir include/create_single_db.sql
|
|
|
|
create schema test_schema;
|
|
create table test_schema.test_table(time bigint, temp float8, device_id text);
|
|
\dt "test_schema".*
|
|
select * from create_hypertable('test_schema.test_table', 'time', 'device_id', 2);
|
|
|
|
--test partitioning in only time dimension
|
|
create table test_schema.test_1dim(time timestamp, temp float);
|
|
select create_hypertable('test_schema.test_1dim', 'time');
|
|
|
|
\dt "test_schema".*
|
|
|
|
select create_hypertable('test_schema.test_1dim', 'time', if_not_exists => true);
|
|
|
|
-- Should error when creating again without if_not_exists set to true
|
|
\set ON_ERROR_STOP 0
|
|
select create_hypertable('test_schema.test_1dim', 'time');
|
|
\set ON_ERROR_STOP 1
|
|
|
|
-- if_not_exist should also work with data in the hypertable
|
|
insert into test_schema.test_1dim VALUES ('2004-10-19 10:23:54+02',1.0);
|
|
select create_hypertable('test_schema.test_1dim', 'time', if_not_exists => true);
|
|
|
|
-- Should error when creating again without if_not_exists set to true
|
|
\set ON_ERROR_STOP 0
|
|
select create_hypertable('test_schema.test_1dim', 'time');
|
|
\set ON_ERROR_STOP 1
|
|
|