mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-28 09:46:44 +08:00
This changes the license text for SQL files to be identical with the license text for C files.
114 lines
2.3 KiB
Plaintext
114 lines
2.3 KiB
Plaintext
-- This file and its contents are licensed under the Apache License 2.0.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-APACHE for a copy of the license.
|
|
CREATE table test_gen (
|
|
id int generated by default AS IDENTITY primary key,
|
|
payload text
|
|
);
|
|
SELECT create_hypertable('test_gen', 'id', chunk_time_interval=>10);
|
|
create_hypertable
|
|
-----------------------
|
|
(1,public,test_gen,t)
|
|
(1 row)
|
|
|
|
insert into test_gen (payload) select generate_series(1,15) returning *;
|
|
id | payload
|
|
----+---------
|
|
1 | 1
|
|
2 | 2
|
|
3 | 3
|
|
4 | 4
|
|
5 | 5
|
|
6 | 6
|
|
7 | 7
|
|
8 | 8
|
|
9 | 9
|
|
10 | 10
|
|
11 | 11
|
|
12 | 12
|
|
13 | 13
|
|
14 | 14
|
|
15 | 15
|
|
(15 rows)
|
|
|
|
select * from test_gen;
|
|
id | payload
|
|
----+---------
|
|
1 | 1
|
|
2 | 2
|
|
3 | 3
|
|
4 | 4
|
|
5 | 5
|
|
6 | 6
|
|
7 | 7
|
|
8 | 8
|
|
9 | 9
|
|
10 | 10
|
|
11 | 11
|
|
12 | 12
|
|
13 | 13
|
|
14 | 14
|
|
15 | 15
|
|
(15 rows)
|
|
|
|
\set ON_ERROR_STOP 0
|
|
insert into test_gen values('1', 'a');
|
|
ERROR: duplicate key value violates unique constraint "1_1_test_gen_pkey"
|
|
\set ON_ERROR_STOP 1
|
|
ALTER TABLE test_gen ALTER COLUMN id DROP IDENTITY;
|
|
\set ON_ERROR_STOP 0
|
|
insert into test_gen (payload) select generate_series(15,20) returning *;
|
|
ERROR: NULL value in column "id" violates not-null constraint
|
|
\set ON_ERROR_STOP 1
|
|
ALTER TABLE test_gen ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY;
|
|
\set ON_ERROR_STOP 0
|
|
insert into test_gen (payload) select generate_series(15,20) returning *;
|
|
ERROR: duplicate key value violates unique constraint "1_1_test_gen_pkey"
|
|
\set ON_ERROR_STOP 1
|
|
ALTER TABLE test_gen ALTER COLUMN id SET GENERATED BY DEFAULT RESTART 100;
|
|
insert into test_gen (payload) select generate_series(15,20) returning *;
|
|
id | payload
|
|
-----+---------
|
|
100 | 15
|
|
101 | 16
|
|
102 | 17
|
|
103 | 18
|
|
104 | 19
|
|
105 | 20
|
|
(6 rows)
|
|
|
|
select * from test_gen;
|
|
id | payload
|
|
-----+---------
|
|
1 | 1
|
|
2 | 2
|
|
3 | 3
|
|
4 | 4
|
|
5 | 5
|
|
6 | 6
|
|
7 | 7
|
|
8 | 8
|
|
9 | 9
|
|
10 | 10
|
|
11 | 11
|
|
12 | 12
|
|
13 | 13
|
|
14 | 14
|
|
15 | 15
|
|
100 | 15
|
|
101 | 16
|
|
102 | 17
|
|
103 | 18
|
|
104 | 19
|
|
105 | 20
|
|
(21 rows)
|
|
|
|
SELECT * FROM test.show_subtables('test_gen');
|
|
Child | Tablespace
|
|
----------------------------------------+------------
|
|
_timescaledb_internal._hyper_1_1_chunk |
|
|
_timescaledb_internal._hyper_1_2_chunk |
|
|
_timescaledb_internal._hyper_1_3_chunk |
|
|
(3 rows)
|
|
|