I would like to drop the sequence used in table and the table itself in one statement using CASCADE, but I’m getting NOTICE and table is not dropped. For example:
CREATE SEQUENCE seq1;
CREATE TABLE t1 (f1 INT NOT NULL DEFAULT nextval('seq1'));
And then when I do:
DROP SEQUENCE seq1 CASCADE;
I get following message, and the table is not dropped:
NOTICE: drop cascades to default for table t1 column f1
I’m definitely doing something wrong but these are my very first steps in PostgreSQL.
The table is never a depending object of an associated sequence and is never dropped by:
Only a column
DEFAULTdrawing from the sequence "depends" on the sequence and is set toNULLif the sequence is deleted withCASCADE.It’s the other way round: if the sequence is owned by a table column it is dropped with:
For a sequence to be owned by a table column you can either use the
serialtype, orALTERan existing sequence: