Drop sequence and cascade

前端 未结 4 1460
粉色の甜心
粉色の甜心 2021-02-05 05:43

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:



        
4条回答
  •  名媛妹妹
    2021-02-05 06:10

    You asked to drop the sequence and cascade that action. While the default can't exist without the sequence, and it is therefore dropped, the table and the column can exist without the sequence, so they remain.

    With the way you've specified this, dropping the table will not drop the sequence, although you can make the sequence depend on the column with which it is used, and therefore have it drop automatically if you drop the table. You can do this by altering the owner of the sequence, or use SERIAL instead. Declaring a column to be type SERIAL automatically creates a sequence, makes it generate a default for the column, and makes that column the owner of the sequence.

提交回复
热议问题