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 1hpDX0-0003P5-ET for pgsql-admin@arkaria.postgresql.org; Sun, 21 Jul 2019 15:13:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hpDWz-00073Q-1g for pgsql-admin@arkaria.postgresql.org; Sun, 21 Jul 2019 15:13:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hpDWy-00073J-Mb for pgsql-admin@lists.postgresql.org; Sun, 21 Jul 2019 15:13:44 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hpDWw-0004Nt-2L for pgsql-admin@lists.postgresql.org; Sun, 21 Jul 2019 15:13:43 +0000 Received: by mail-ot1-x331.google.com with SMTP id j11so13348227otp.10 for ; Sun, 21 Jul 2019 08:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:cc:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=DKahcqzzCcg+mxgSQ2qWfmgOmK+WZ2fusPlhZS674go=; b=VbAVMPN03NpuOyQZhHAk9hYdTLq8CVuDevWODR20WglXnPm5st8xQwSZJ9UMvL5dU5 NYe+Gq2NqDWB5MAlwxzRzudQcgEi8ko5YfUqECaPa1T076Y9OtVWdo0BQPpbNoJIoC/S T4ksgKkkLnnV1ADk6cVMFKaz1F9KJc8JjlIcgwcBTnEbBcVduRTyzsvyNZXY3Gt5leQl j57Wu+PI+T5yXX8OoxLaxcs0aY9eQ7G28VMutph8QuFz+tT8fBw6hcgJBoWSK84WXl9V Z3fqMvWIcBCh8E1rUX3dcqVJPqLnxrechgkCafI0ksBrr/Wy1IzuJnVn3DwcJN+GPRLq 20Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=DKahcqzzCcg+mxgSQ2qWfmgOmK+WZ2fusPlhZS674go=; b=jOsB2Q1bz0OhJOWne+iDWAQeeoEM6s2u4fmYzCTnWoE1mpgzrJB683LXcnCKufmJHL 6W1rYfWl5l7idkWr1kyDUG5/+bgvglLpVUapc+DukA9p2WYLVVllQOtL+SYxRY+X9dv+ vPIXVqQe1BDq8rx7azdxhIEXuBFHDz5fs6rI04rONKcD7Vw20r2e8baiRfjZqk+GtxHc KcXp8hYpyRM0GV1zBf2WQ63Ct1mnQTzYLVNsj2x3ac8EKWvW1rFaKNbBFTpVHoecU6aT GB6veMYLtBVRQgQQyQVoZImh8w5jpGNmravMORdPJVUT8TLjPQkpwmX3R/5CLfB5xPrE wxVg== X-Gm-Message-State: APjAAAU2gZi/Cra36IUGdkfkLGsDDoVFDYcuR92l4KFuQkVHpR0aKYmx +uQgZguxpj75TXLcuGdrOMGYbR/3FKg= X-Google-Smtp-Source: APXvYqwKVtYavA3WzOynDSpeepqiUqo7EAYBFVvLFb9mYihJn3ZnQR1VbLpoHoZyfRCYwV8q1pUZKg== X-Received: by 2002:a05:6830:1303:: with SMTP id p3mr46809166otq.267.1563722019268; Sun, 21 Jul 2019 08:13:39 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id r130sm13312122oib.41.2019.07.21.08.13.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jul 2019 08:13:38 -0700 (PDT) Subject: Re: How do I alter an existing column and add a foreign key which is a Primary key to a table? Cc: pgsql-admin@lists.postgresql.org References: <820008379.2579287.1563670685484@mail.yahoo.com> <5CE41E80-274A-44DA-9553-E2DCA260F751@jakobs.com> <385857992.2643116.1563717238725@mail.yahoo.com> <923fb3b1-90e9-e0b5-bc5b-d896128c3f28@gmail.com> <1745586001.2633224.1563719075867@mail.yahoo.com> <905425626.2686338.1563721213121@mail.yahoo.com> <2030754658.2646264.1563721831668@mail.yahoo.com> From: Ron Message-ID: <75125c45-0fed-e5f1-50f0-9646db20dde6@gmail.com> Date: Sun, 21 Jul 2019 10:13:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <2030754658.2646264.1563721831668@mail.yahoo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/21/19 10:10 AM, Karen Goh wrote: > > On Sunday, July 21, 2019, 11:06:16 PM GMT+8, David G. Johnston > wrote: > > > On Sunday, July 21, 2019, Karen Goh wrote: > > > Is there a way for me to generate an entity table diagram vis pgAdmin4 or > PSQL ? > > > Just write the 5 or so tables out in a somewhat compressed format. Psql > doesn’t and I don’t know about pgadmin > > Here is a compressed format : > > s_tutor > -------- > zipcode(text) > tutor_id (I just checked this is becomes a 'serial id ?' based on the > generated sql > > ALTER TABLE public.s_tutor ALTER COLUMN tutor_id ADD GENERATED BY DEFAULT > AS IDENTITY ( > SEQUENCE NAME public.tutor_strtutorid_seq > START WITH 1 > INCREMENT BY 1 > NO MINVALUE > NO MAXVALUE > CACHE 1 > ); > > tutor_subject > ---------------- > tutor_id > subject_Names select s_tutor.zipcode from s_tutor, tutor_subject where s_tutor.tutor_id = tutor_subject.tutor_id   and tutor_subject.subject_names ='Angela Merkel' -- Angular momentum makes the world go 'round.