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;
17 SELECT * FROM truncate_a;
24 -- Commit the truncate this time
28 SELECT * FROM truncate_a;
33 -- Test foreign constraint check
34 CREATE TABLE truncate_b(col1 integer references truncate_a);
35 NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
36 INSERT INTO truncate_a VALUES (1);
37 SELECT * FROM truncate_a;
44 ERROR: cannot truncate a table referenced in a foreign key constraint
45 DETAIL: Table "truncate_b" references this one via foreign key constraint "$1".
46 SELECT * FROM truncate_a;
52 DROP TABLE truncate_b;
53 DROP TABLE truncate_a;