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 1i8O2j-0007qI-5i for pgsql-sql@arkaria.postgresql.org; Thu, 12 Sep 2019 12:17:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8O2i-0000ct-1M for pgsql-sql@arkaria.postgresql.org; Thu, 12 Sep 2019 12:17:44 +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 1i8O2h-0000cg-LO for pgsql-sql@lists.postgresql.org; Thu, 12 Sep 2019 12:17:43 +0000 Received: from sonic306-1.consmr.mail.bf2.yahoo.com ([74.6.132.40]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i8O2e-0004IC-Ju for pgsql-sql@lists.postgresql.org; Thu, 12 Sep 2019 12:17:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1568290658; bh=+IqFwlumL6NkJ50gDCJGh99aOC9CP6FVTI99KAkuoT4=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject; b=tinGPgfht7F5nbh5Xk0n++T9xzJp6W9nLDqsNZXQdufTFIEwCaKSBthSXanyWFhljfewVj6oka84rM2+6L7PZAotVjkk1P5UdriFgXX/VoBY7pHY6YxqcBG27vm59GIL0M4sweVZC4PFnPT5wYWKjqzV3m4olc2iMn1dbHYZEuN76BXjM1qS2Q1N6Oc5hnpFew0YdGOolrdMKAEjZtOsNhwxq1oHrMLA5pRMuXHVpGnl/3PsW0LXhV3s+/bwUCF/PRaiJa5LnwCcarNHhO4T85Wcg677Bed/+/2nzMkG+KuNPoFj5SjKtL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PifuY3dvWq7QerDmK7Ave4vm5MPejmDz4ombaZD5AxLeBF2GcOAeaKwibTf06YPRDXAPP5ZAN xHjQRl8B4q1hXJ2agg2B2spxhlCJaX9g7lWI0zbYXJb70KcmyBWCA.gHjB60acc10SdzexN4MrFh XdSDG0mozAgY2Pnrc_MeM00eAOEL9n7PHC8EpSRROtdgK4Ga15yJ4uA2diL8mdLmrIh3h6Hsjidy kMdxZzogIjOgSp4d8JPqjsWppqDRHQg9XXq6U8mUC_xhpPBLhnfKeSur59TIxt3MKaX6oz59E0Dy JDjZY7CF.gu4y9_P_WDOxtfhhj4kF8xarhUuGGg6HIYYCc3sx Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.bf2.yahoo.com with HTTP; Thu, 12 Sep 2019 12:17:38 +0000 Date: Thu, 12 Sep 2019 12:17:34 +0000 (UTC) From: Karen Goh To: Steve Midgley Cc: Message-ID: <54081241.4161366.1568290654776@mail.yahoo.com> In-Reply-To: References: <207445330.2444743.1567859173939@mail.yahoo.com> <27D5F961-0A53-4819-9558-B2C685D0AB30@gmail.com> <1282323688.2470443.1567868674196@mail.yahoo.com> <2B0FF25B-F26A-4FA5-9CD6-D58AF5A534EB@gmail.com> <1179111273.2587909.1567915911716@mail.yahoo.com> <53C1E987-E6CD-45D2-8299-4E23D6A6C9D4@gmail.com> <642386474.2839394.1568005604966@mail.yahoo.com> <1105744936.4152325.1568285419687@mail.yahoo.com> Subject: Re: How do I enabled Windows 10 to be able to run PSQL etc MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4161365_155574332.1568290654775" X-Mailer: WebService/1.1.14303 YahooMailIosMobile Yahoo%20Mail/46873 CFNetwork/978.0.7 Darwin/18.6.0 Content-Length: 7417 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_4161365_155574332.1568290654775 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sent from Yahoo Mail for iPhone On Thursday, September 12, 2019, 8:07 PM, Steve Midgley wrote: On Thu, Sep 12, 2019 at 11:50 AM Karen Goh wrote: Anyway, now my problem is that i get a=20 org.postgresql.util.PSQLException: ERROR: null value in column "parent_id" = violates not-null constraint I'd like to know since I have already made parent_id a primary key, do I ne= ed to put a idenity as ALWAYS and increment by 1 ? cos another table I had used pgAdmin4 to define it as identity, ALWAYS, inc= rement 1 and it works well.... so what is the difference between identity and PRIMARY KEY ? and if I follow the other table definition for id and put in the ALWAYS, it= will give me another problem...that the generated_id doesn't get inserted = even though it should not=20 Hi Karen, Please bottom post on this forum - it's uncommon these days, but the custom= on this email list to post replies at the bottom of the email. Regarding your question about nulls and primary keys -- yes you want to def= ine, where it makes sense, to use autoincrementing primary keys, if you wan= t the system to manage your keys. Note that autoincrementing IDs, if expose= d to the public via the web or similar, could create some security issues. Hi Steve, Sorry yahoo mail is giving me lots of problems in typing at the bottom - th= e convention.=C2=A0 I would like to confirm how to make an ID =C2=A0in PostgreSQL auto incremen= t like MySQL? And since I need to have generated key to be retrieved before inserting int= o the join table, if I don=E2=80=99t do it via web how can I do it then?=C2= =A0 But in many cases it makes a lot of sense to use them. To create a primary = key that autoincrements, use the "serial" or "bigserial" datatype. Combined= with a primary key (that enforces "not null" among other things), your cre= ate table would look like this:CREATE TABLE sample ( id SERIAL PRIMARY KEY, ); Why is my another table, without making the id serial it is auto-incrementi= ng? I have not tested it, but I'd guess you should be able to alter a table tha= t has an integer primary key and convert it to a serial. I hope that's help= ful! Steve ------=_Part_4161365_155574332.1568290654775 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Sent fr= om Yahoo Mail for iPhone

On T= hursday, September 12, 2019, 8:07 PM, Steve Midgley <science@misuse.org&= gt; wrote:

On Thu, Sep 12, 2019 at 11:50 AM Karen Go= h <karenworld@yah= oo.com> wrote:
Anyway, now my prob= lem is that i get a

org.postgresql.ut= il.PSQLException: ERROR: null value in column "parent_id" violates not-null= constraint

I'd like to know since I h= ave already made parent_id a primary key, do I need to put a idenity as ALW= AYS and increment by 1 ?

cos another t= able I had used pgAdmin4 to define it as identity, ALWAYS, increment 1 and = it works well....

so what is the diffe= rence between identity and PRIMARY KEY ?

and if I follow the other table definition for id and put in the ALWAYS,= it will give me another problem...that the generated_id doesn't get insert= ed even though it should not

Hi Karen,

Please bottom pos= t on this forum - it's uncommon these days, but the custom on this email li= st to post replies at the bottom of the email.

Regarding your question about nulls and primary keys -- yes you= want to define, where it makes sense, to use autoincrementing primary keys= , if you want the system to manage your keys. Note that autoincrementing ID= s, if exposed to the public via the web or similar, could create some secur= ity issues.

Hi Steve,

Sor= ry yahoo mail is giving me lots of problems in typing at the bottom - the c= onvention. 

I would like to confirm how to ma= ke an ID  in PostgreSQL auto increment like MySQL?

And since I need to have generated key to be retrieved before inserti= ng into the join table, if I don=E2=80=99t do it via web how can I do it th= en? 

But in many cases it make= s a lot of sense to use them. To create a primary key that autoincrements, = use the "serial" or "bigserial" datatype. Combined with a primary key (that= enforces "not null" among other things), your create table would look like= this:
CREATE TABLE sample (
  id              SERIAL PRIMARY KEY,
);

Wh=
y is my another table, without making the id serial it is auto-incrementing=
?

=
I have not tested it, but I'd guess you should =
be able to alter a table that has an integer primary key and convert it to =
a serial. I hope that's helpful! Steve

=
------=_Part_4161365_155574332.1568290654775--