Обсуждение: sequence havn't been dropped.

Поиск
Список
Период
Сортировка

sequence havn't been dropped.

От
Bhuvan A
Дата:
hi,

Hope you might have came accross this problem earlier. it exists in
7.1.x and 7.2 as well.

while creating a table with a column of type 'serial', well a sequence
has been created and the default value of that field is set to nextval
of that sequence, fine. But while dropping that table, why aren't that
sequence dropped?

example:

bhuvandb=# CREATE TABLE seq_test (id serial, name text);
NOTICE:  CREATE TABLE will create implicit sequence 'seq_test_id_seq'
for SERIAL column 'seq_test.id'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index
'seq_test_id_key' for table 'seq_test'
CREATE

bhuvandb=# DROP TABLE seq_test ;
DROP

bhuvandb=# CREATE TABLE seq_test (id serial, name text);
NOTICE:  CREATE TABLE will create implicit sequence 'seq_test_id_seq'
for SERIAL column 'seq_test.id'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index
'seq_test_id_key' for table 'seq_test'

ERROR:  Relation 'seq_test_id_seq' already exists

hope, developers would have their own reasons. but wish to know
that. thats it.

Regards,
Bhuvaneswaran.

Re: sequence havn't been dropped.

От
Peter Eisentraut
Дата:
Bhuvan A writes:

> while creating a table with a column of type 'serial', well a sequence
> has been created and the default value of that field is set to nextval
> of that sequence, fine. But while dropping that table, why aren't that
> sequence dropped?

The sequence isn't owned by the table.  It might be used elsewhere as
well.

--
Peter Eisentraut   peter_e@gmx.net