Re: Changing the Primary Key Column

From: Brian Kurle <bk(at)travelingbits(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pdxpug(at)postgresql(dot)org
Subject: Re: Changing the Primary Key Column
Date: 2011-02-24 15:14:35
Message-ID: E052B4A2-E9B9-467E-AACD-F2866D2E0722@travelingbits.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pdxpug


Try

# alter table water_well alter column sequence_no drop not null;
# commit;

http://www.java2s.com/Code/PostgreSQL/Constraints/ALTERTABLEemployeeALTERCOLUMNidDROPNOTNULL.htm

Brian Kurle
President
Traveling bits, Inc.
Cell: 503 961-2489
Fax: 503 640-3814

On Feb 24, 2011, at 6:20 AM, Rich Shepard wrote:

> On Wed, 23 Feb 2011, Joshua D. Drake wrote:
>
>>>> alter table drop constraint
>>>> alter table drop column
>>>> alter table add primary key
>
>> That doesn't make sense. Paste your output please.
>
> nevada-# alter table water_well drop constraint 'not null'
> nevada-# alter table water_well drop column 'sequence_no'
> nevada-# alter table water_well add primary key 'well_log'
> nevada-# commit;
> ERROR: syntax error at or near "alter"
> LINE 2: alter table water_well drop constraint 'not null'
> ^
> nevada=#
>
> Must be user error; I don't see the variables quoted on the alter table
> doc page, but that makes no difference:
>
> nevada=# alter table water_well drop constraint not null
> nevada-# alter table water_well drop column sequence_no
> nevada-# alter table water_well add primary key well_log
> nevada-# commit;
> ERROR: syntax error at or near "not"
> LINE 1: alter table water_well drop constraint not null
> ^
> nevada=#
>
> Schema's unchanged:
>
> Table "public.water_well"
> Column | Type | Modifiers --------------------+-----------------------+-----------
> sequence_no | text | not null
> well_log | text |
>
> Elucidation needed.
>
> Thanks,
>
> Rich
>
> --
> Sent via pdxpug mailing list (pdxpug(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pdxpug
>

In response to

Responses

Browse pdxpug by date

  From Date Subject
Next Message Brent Dombrowski 2011-02-24 15:21:27 Re: Changing the Primary Key Column
Previous Message Rich Shepard 2011-02-24 14:20:32 Re: Changing the Primary Key Column