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
INSERT INTO truncate_a VALUES (1);
36
SELECT * FROM truncate_a;
43
ERROR: cannot truncate a table referenced in a foreign key constraint
44
DETAIL: Table "truncate_b" references "truncate_a" via foreign key constraint "truncate_b_col1_fkey".
45
SELECT * FROM truncate_a;
51
DROP TABLE truncate_b;
52
DROP TABLE truncate_a;