From: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | Guilherme <antoniolo(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: drop table cascade doesn't drop manual sequences |
Date: | 2007-10-14 13:37:57 |
Message-ID: | dcc563d10710140637s198253c9pe97ba89aa98bcf0b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 10/10/07, Guilherme <antoniolo(at)gmail(dot)com> wrote:
> Hello folks,
>
> I'm new to postgres and I'm using version 8.1
>
> Here's the problem anyway:
>
> If I insert a sequence later on table creation with alter table, drop
> table cascade simply doesn't drop this sequence even when I specify
> CASCADE.
This is normal.
> works
> ####################
>
> create table bla(id serial);
> drop table bla CASCADE;
> select * from pg_class were relkind = 'S' => nothing
Here, the sequence was created as a dependent object of the table.
> doesn't
> ####################
>
> create table bla(id integer);
> create sequence bla_id_seq;
> alter table bla alter column id set default nextval('bla_id_seq');
>
> drop table bla CASCADE;
> select * from pg_class were relkind = 'S' => 'bla_id_seq'
Here the sequence was created independently. this method is often
used when a sequence needs to be shared by >1 table:
create table bla(id integer);
create table bla2(id integer);
create sequence bla_id_seq;
alter table bla alter column id set default nextval('bla_id_seq');
alter table bla2 alter column id set default nextval('bla_id_seq');
Now, if i drop table bla2 should I lose the sequence that I assigned
to be used by bla?
From | Date | Subject | |
---|---|---|---|
Next Message | Syan Tan | 2007-10-14 14:00:05 | Re: atomic commit; begin for long running transactions , in combination with savepoint. |
Previous Message | Scott Marlowe | 2007-10-14 13:30:17 | Re: corrupt database? |