]> granicus.if.org Git - postgresql/blob - src/test/regress/expected/truncate.out
Message editing: remove gratuitous variations in message wording, standardize
[postgresql] / src / test / regress / expected / truncate.out
1 -- Test basic TRUNCATE functionality.
2 CREATE TABLE truncate_a (col1 integer primary key);
3 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "truncate_a_pkey" for table "truncate_a"
4 INSERT INTO truncate_a VALUES (1);
5 INSERT INTO truncate_a VALUES (2);
6 SELECT * FROM truncate_a;
7  col1 
8 ------
9     1
10     2
11 (2 rows)
12
13 -- Roll truncate back
14 BEGIN;
15 TRUNCATE truncate_a;
16 ROLLBACK;
17 SELECT * FROM truncate_a;
18  col1 
19 ------
20     1
21     2
22 (2 rows)
23
24 -- Commit the truncate this time
25 BEGIN;
26 TRUNCATE truncate_a;
27 COMMIT;
28 SELECT * FROM truncate_a;
29  col1 
30 ------
31 (0 rows)
32
33 -- Test foreign constraint check
34 CREATE TABLE truncate_b(col1 integer references truncate_a);
35 NOTICE:  CREATE TABLE will create implicit triggers for foreign-key checks
36 INSERT INTO truncate_a VALUES (1);
37 SELECT * FROM truncate_a;
38  col1 
39 ------
40     1
41 (1 row)
42
43 TRUNCATE truncate_a;
44 ERROR:  cannot truncate a table referenced in a foreign key constraint
45 DETAIL:  Table "truncate_b" references "truncate_a" via foreign key constraint "$1".
46 SELECT * FROM truncate_a;
47  col1 
48 ------
49     1
50 (1 row)
51
52 DROP TABLE truncate_b;
53 DROP TABLE truncate_a;