Re: Remove Modifiers on Table

From: Bosco Rama <postgres(at)boscorama(dot)com>
To: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Remove Modifiers on Table
Date: 2011-05-16 20:58:38
Message-ID: 4DD18FFE.9000801@boscorama.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Carlos Mennens wrote:
> I created a modifier for auto incrementing my primary key as follows:
>
> records=# \d users
> Table "public.users"
> Column | Type | Modifiers
> --------+-----------------------+----------------------------------------------------
> id | integer | not null default
> nextval('users_seq_id'::regclass)
> fname | character varying(40) | not null
> lname | character varying(40) | not null
> email | character varying(40) | not null
> office | character varying(5) | not null
> dob | date | not null
> title | character varying(40) | not null
> Indexes:
> "users_pkey" PRIMARY KEY, btree (id)
> "users_email_key" UNIQUE, btree (email)
>
> I recently tried to remove the modifier and it failed because it was
> associated with the 'id' column so my question is how do I remove /
> delete the modifier so I can delete the sequence I created to auto
> increment my 'id' value? I don't want to drop the id column / loss my
> column data, I just want to remove the associated modifier so I can
> drop the sequence.

If you are truly intent on removing the sequence you'll need to do the
following:

alter sequence users_seq_id owned by NONE
alter table users alter column id drop default
drop sequence users_seq_id

HTH

Bosco.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Opena 2011-05-16 21:01:42 Re: Client-based EOFs triggering hung queries?
Previous Message Tom Lane 2011-05-16 20:04:46 Re: Client-based EOFs triggering hung queries?