From: | Brent Dombrowski <brent(dot)dombrowski(at)gmail(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:21:27 |
Message-ID: | 58862DF7-1864-46F2-9237-B8720DABC230@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pdxpug |
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=#
'not null' is a column constraint, not the table constraint. Look for the table constraint at the bottom of the table description. It will likely be something like table_pkey. Here is a sample from a test database I have:
Table "public.person"
Column | Type | Modifiers
--------+-----------------------+-----------
id | integer | not null
ssn | integer |
name | character varying(32) |
phone | character(12) |
Indexes:
"person_pkey" PRIMARY KEY, btree (id)
test=# alter table person drop constraint "person_pkey";
ALTER TABLE
test=# \d person
Table "public.person"
Column | Type | Modifiers
--------+-----------------------+-----------
id | integer | not null
ssn | integer |
name | character varying(32) |
phone | character(12) |
Brent.
From | Date | Subject | |
---|---|---|---|
Next Message | Rich Shepard | 2011-02-24 15:51:50 | Re: Changing the Primary Key Column |
Previous Message | Brian Kurle | 2011-02-24 15:14:35 | Re: Changing the Primary Key Column |