Skip to content

Instantly share code, notes, and snippets.

@sploiselle
Last active August 12, 2016 13:00
Show Gist options
  • Save sploiselle/4e81c7e2f89f9b9690aa6420708287d5 to your computer and use it in GitHub Desktop.
Save sploiselle/4e81c7e2f89f9b9690aa6420708287d5 to your computer and use it in GitHub Desktop.

I don't think TRUNCATE's CASCADE clause works (or if it does, it doesn't work like Postgres).

> CREATE TABLE reftbl (id INT PRIMARY KEY);
CREATE TABLE

> INSERT INTO reftbl VALUES (1);
INSERT 1

> CREATE TABLE fktbl (id INT REFERENCES reftbl, INDEX (id));
CREATE TABLE

> INSERT INTO fktbl VALUES (1);
INSERT 1

> TRUNCATE reftbl CASCADE;
pq: foreign key violation: non-empty columns [id] referenced in table "fktbl"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment