Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iFjkZ-0007GX-7W for pgsql-general@arkaria.postgresql.org; Wed, 02 Oct 2019 18:53:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iFjkY-00030j-0t for pgsql-general@arkaria.postgresql.org; Wed, 02 Oct 2019 18:53:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iFjkB-0007WI-FV for pgsql-general@lists.postgresql.org; Wed, 02 Oct 2019 18:52:59 +0000 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iFjk8-0005Fb-Tk for pgsql-general@lists.postgresql.org; Wed, 02 Oct 2019 18:52:58 +0000 Received: by mail-ot1-x344.google.com with SMTP id s22so100441otr.6 for ; Wed, 02 Oct 2019 11:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=xx8ru4xBLeu3MsGvwFmQv/i3vmUdhNItfEd/ov/eN8g=; b=lnBXNawZ+96aewRYsdn9UZ7w60M9PwXqNaUjrAB0Sy4wZknbIxoREOZFxuEo92jP0S 3siv2mePV5iKXveBNpuGcfmU7MvRa1hi8LWjTxjT/Q73SQeUy8NC3qaQ/HDc8R9gax3+ xpDptH8UPJ2VawP5Xkqs5azvcElUWyf5Jt2defSH1l0gI2vgfz11ce5yq876Z7uzyPjX DatWIDUazMXpt41ppr+VT0HpgZJ8Hj7IabIuEv6X+KJ92yXpkjxA8FRZnO2kFe0VcJAU O4kzm1JxKeeLyFfLWg4cwVdu/a31nJ0BOfjXvVqDlO++SJdvncqZywW3GPl3jtq8kpMb EMTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=xx8ru4xBLeu3MsGvwFmQv/i3vmUdhNItfEd/ov/eN8g=; b=Aki+1ugAzdstkgtdf4HbEO+9NA2bVXy0x/hUDNJlzUf53ia9cHykqT3WNrLAiVHvks BOxKEHxknwf5nAkg8DDDvKnnx3p4gNyL2WtV+h3f8euWmKKZ5U0MlglYP2Vxf0dTzRL/ rfbt5vs2VxIyeP9k1EsOdXYQ5ikVEEUey6Nae42uA4mtLrAUInSLdrX21KtlxVGVgWjU 3C4lunDHmTq8mBigCu2luHaLTS5RIrl2gjTzt8caJFbHe1MHiE18xpaN+xEQ3Qv7Sa5p OMWjCXOBB9QCTa9/cV0Fa7rpysu4qOF+Ub7JZBUV2+usSBH/L5wGjl548HFqXW6v/dTP xRaQ== X-Gm-Message-State: APjAAAXopQhFp2s6bXZc/owzK/Wnrlx8AxkVvYHeGsVla+TVeTfS+XDK 7f4oZsj889RAIn7ffFQkJF0a5aIAXpvlHA== X-Google-Smtp-Source: APXvYqzF75EEXyBO4iIP/p2g+ZusyDYt2VuHH93RuPzj5YEzrWEi+qpOGq4gohVUV3GevwH+LyfZBg== X-Received: by 2002:a05:6830:1015:: with SMTP id a21mr303478otp.300.1570042375979; Wed, 02 Oct 2019 11:52:55 -0700 (PDT) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id r187sm78089oie.17.2019.10.02.11.52.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Oct 2019 11:52:55 -0700 (PDT) Subject: Re: Drop a primary To: pgsql-general@lists.postgresql.org References: <566B8778-F815-4562-A325-B40952EF7494@northwestern.edu> From: Ron Message-ID: Date: Wed, 2 Oct 2019 13:52:54 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <566B8778-F815-4562-A325-B40952EF7494@northwestern.edu> Content-Type: multipart/alternative; boundary="------------086BDB5A6BFF112D50EFE9AF" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------086BDB5A6BFF112D50EFE9AF Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 10/2/19 1:48 PM, Martin Mueller wrote: > > I created a primary key with the following commands > > Add id serial > > Add primary key (id) > > I cannot figure out from the documentation how to drop that column. > Drop it just like you added it: test=# alter table foobar add id serial; ALTER TABLE test=# alter table foobar add primary key(id); ALTER TABLE test=# alter table foobar drop id; ALTER TABLE -- Angular momentum makes the world go 'round. --------------086BDB5A6BFF112D50EFE9AF Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 10/2/19 1:48 PM, Martin Mueller wrote:

I created a primary key with the following commands

 

Add id serial

Add primary key (id)

 

I cannot figure out from the documentation how to drop that column.


Drop it just like you added it:

test=# alter table foobar add id serial;
ALTER TABLE
test=# alter table foobar add primary key(id);
ALTER TABLE
test=# alter table foobar drop id;
ALTER TABLE


--
Angular momentum makes the world go 'round.
--------------086BDB5A6BFF112D50EFE9AF--