Re: Use of Serial Datatype and Sequence Issue

From: Keary Suska <hierophant(at)pcisys(dot)net>
To: Tom Innes <tinnes(at)inforamp(dot)net>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Use of Serial Datatype and Sequence Issue
Date: 2001-11-05 20:03:54
Message-ID: B80C3EBA.6092%hierophant@pcisys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers pgsql-general

The message may be a bit misleading. using a SERIAL data type actually means
that you are implicitly creating a sequence. A sequence is a separate
object, not tied to any column. Data type SERIAL is just shorthand for
defining an INT4 column and a sequence object with a DEFAULT clause on the
column calling the sequence. You can do this explicitly as well. The docs
may not be clear about this relationship. Hence, you have to drop the
sequences explicitly if you don't want them anymore.

IMHO, when you do a data-only pg_dump as SQL inserts, the fact that SQL to
create sequences is dumped as well seems a bug to me. Any plans to change
this, Tom Lane?

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

> From: Tom Innes <tinnes(at)inforamp(dot)net>
> Organization: Excite(at)Home - The Leader in Broadband http://home.com/faster
> Date: Fri, 02 Nov 2001 00:28:18 GMT
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] Use of Serial Datatype and Sequence Issue
>
> I am new to postgres and am in the process of creating a new database of
> several 100 tables. Most of the tables have a serial datatype. When the
> table is created psql says it is creating an implicit sequence. Yet
> when I drop the table and even when I drop the database the sequence is
> still there. When I try to re-create the table it fails beacuse the
> sequence already exists. This same behaviour exists for indexes. How
> can I get rid of any sequences or indexes that have been created. I
> would prefer not to explicitly drop each one. Ideally I would like to
> drop the table and have all related indexes, sequences dropped.
>
> Tom
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Martín Marqués 2001-11-05 23:14:54 Re: Use of Serial Datatype and Sequence Issue
Previous Message Doug McNaught 2001-11-05 17:57:09 Re: Use of Serial Datatype and Sequence Issue

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-11-05 20:33:03 Re: Daylight Savings Time
Previous Message X 2001-11-05 18:13:15 copy command with PSQL