aboutsummaryrefslogtreecommitdiff
path: root/src/test/regress/expected/sequence.out
blob: 49b783a805a69f6d1c179d4f5cf05b12280bae82 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
--- test creation of SERIAL column
---
 
CREATE TABLE serialTest (f1 text, f2 serial);
NOTICE:  CREATE TABLE will create implicit sequence "serialtest_f2_seq" for "serial" column "serialtest.f2"
 
INSERT INTO serialTest VALUES ('foo');
INSERT INTO serialTest VALUES ('bar');
INSERT INTO serialTest VALUES ('force', 100);
INSERT INTO serialTest VALUES ('wrong', NULL);
ERROR:  null value in column "f2" violates not-null constraint
 
SELECT * FROM serialTest;
  f1   | f2  
-------+-----
 foo   |   1
 bar   |   2
 force | 100
(3 rows)

 
CREATE SEQUENCE sequence_test;
 
BEGIN;
SELECT nextval('sequence_test');
 nextval 
---------
       1
(1 row)

DROP SEQUENCE sequence_test;
END;
-- renaming sequences
CREATE SEQUENCE foo_seq;
ALTER TABLE foo_seq RENAME TO foo_seq_new;
SELECT * FROM foo_seq_new;
 sequence_name | last_value | increment_by |      max_value      | min_value | cache_value | log_cnt | is_cycled | is_called 
---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
 foo_seq       |          1 |            1 | 9223372036854775807 |         1 |           1 |       1 | f         | f
(1 row)

DROP SEQUENCE foo_seq_new;
--
-- Alter sequence
--
CREATE SEQUENCE sequence_test2 START WITH 32;
SELECT nextval('sequence_test2');
 nextval 
---------
      32
(1 row)

ALTER SEQUENCE sequence_test2 RESTART WITH 16
	 INCREMENT BY 4 MAXVALUE 22 MINVALUE 5 CYCLE;
SELECT nextval('sequence_test2');
 nextval 
---------
      16
(1 row)

SELECT nextval('sequence_test2');
 nextval 
---------
      20
(1 row)

SELECT nextval('sequence_test2');
 nextval 
---------
       5
(1 row)