Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHqEb-00B8tA-F6 for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 19:35:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sHqEY-006QQz-Uj for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 19:35:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHqEY-006QQq-Iz for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 19:35:43 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sHqEX-001Vyh-0s for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 19:35:42 +0000 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3c9b74043b1so668199b6e.1 for ; Thu, 13 Jun 2024 12:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718307339; x=1718912139; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FMjIFarD1Z93uhMgsI1nMKoZ5vtg3LhgFsZi7kaDQJY=; b=M0BOr4ZGHoJ4wAk9WyLm8BfvZsSayUs/1fbcD3gdzt6FJWPYRZeJR3sSLVQ6d7NOUM hdhj0S7E1sA1jnPOCk+QASHtG5qhpAZ4tW+F68N5b51nMJaZ8iovDFRE0doH9GScHsQM m2NdeKKpK5Cl5rOvdBjvbcYRoXRSJ/C+NF+ljSQMC452zYjJ2mxfuPjc7qPKol3/zMIS Vz1fIEpgkchu7ipxodhDUsJeLKiiXEQI4E8q2HtcMAOVNyOklnBY9KGJJhKPhqtcjzNT 7EEMsW53ERRPxahNMIDvPUDBw7pO+jV0JI6xo7YTlCYJdYYxdcdCIVLIATSMkrXW2EbJ +SpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718307339; x=1718912139; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FMjIFarD1Z93uhMgsI1nMKoZ5vtg3LhgFsZi7kaDQJY=; b=glVoAslLcLL++KQqq06V8NCo5x/VLK4f4jfuGDe7LyfPyvoD9w65Tud47bXUpzqDY9 4KQFORyaxTZ6O2WwTj4gmcVy8MeMqookCTGIeb5xNWG0mFlBeI6NVfRPsgikemkle3kr 2wwWWnKmTvk60I6T9pgvAUGtWwK5fhmaJstLd3V6Cjvu57fxuzZlaz56sAJtz4RoZe6q 89B1L3m46tlFoUkkvVMtSt9Ac1tZ3nJMnyrm4AFOYX6FxtV9aH5b6Unt620zLbx7zKLB ths3/wYNEu+49EEvbENzV0jxBVeWtz1s1R8pAmZ80yMPEaAHKpDMJ9+4NLVXVfSyu7rr MG7A== X-Gm-Message-State: AOJu0YxBYuZ5BCOCSjUP3sYItgZmvr3/98xvSJotUiCn6Q/r79ocXu/a wJSWA9OonNSY2XpxGw8nAt+2omRLsVh1NvPlO9YE/SyaOnRiReilD728P6zuxH98vY3qjIXUG7y n+JvnA11IsyUgbQ0aCB2vH88b38cpgQ== X-Google-Smtp-Source: AGHT+IG5OTQimzL1LAN3xnQvB5ydVoF7Iyu3+qankoQ9/qXALf7lR+dz3n1OA3y6ixJMkE46mxf3Wh5d3wX9bXM8rRs= X-Received: by 2002:a05:6870:7187:b0:254:8ebf:e562 with SMTP id 586e51a60fabf-25842c14799mr595648fac.51.1718307339058; Thu, 13 Jun 2024 12:35:39 -0700 (PDT) MIME-Version: 1.0 References: <387fa6c2-5de-f24-d522-46282597703@appl-ecosys.com> <1b139d9a-b95f-f7c8-52fb-9d7442c69ad9@appl-ecosys.com> In-Reply-To: <1b139d9a-b95f-f7c8-52fb-9d7442c69ad9@appl-ecosys.com> From: "David G. Johnston" Date: Thu, 13 Jun 2024 12:35:01 -0700 Message-ID: Subject: Re: Reset sequence to current maximum value of rows To: Rich Shepard Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000008f484d061aca9a88" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000008f484d061aca9a88 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 13, 2024 at 11:24=E2=80=AFAM Rich Shepard wrote: > On Thu, 13 Jun 2024, David G. Johnston wrote: > > > You need to show your work here. As your PK is a number it cannot have= a > > company name as a value and so this doesn't make sense. > > insert into companies (company_nbr,company_name,industry,status) values > (DEFAULT,'new company name','Industry','Opportunity') > > With DEFAULT as the company_nbr why can't the company_name not have a > value? > Because you specified company_name in the column listing for the things you are inserting values for. So in column position 2 you must have a value than can be inserted into the company_name column. It is utterly immaterial how you specified the value for column position 1. > > If you use the default when inserting the next value in the sequence is > > used. > > Yes, that's the theory. It didn't work for me and why it didn't is what I > want to understand. > > We can't help you understand if you don't show a complete working example and ask a question in relation to that example. I suggest you start from scratch, this time using scripts, so that your work is recorded and replayable. David J. --0000000000008f484d061aca9a88 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Jun 13, 2024 at 11:24=E2=80=AFAM Rich Shepard <= rshepard@appl-ecosys.com>= ; wrote:
On Thu, 13 Jun 2024, David G. Johnston wro= te:

> You need to show your work here.=C2=A0 As your PK is a number it canno= t have a
> company name as a value and so this doesn't make sense.

insert into companies (company_nbr,company_name,industry,status) values
(DEFAULT,'new company name','Industry','Opportunity'= ;)

With DEFAULT as the company_nbr why can't the company_name not have a v= alue?

Because you specified company_= name in the column listing for the things you are inserting values for.=C2= =A0 So in column position 2 you must have a value than can be inserted into= the company_name column.=C2=A0 It is utterly immaterial how you specified = the value for column position 1.


> If you use the default when inserting the next value in the sequence i= s
> used.

Yes, that's the theory. It didn't work for me and why it didn't= is what I
want to understand.


We can't help= you understand if you don't show a complete working example and ask a = question in relation=C2=A0to that example.=C2=A0 I suggest you start from s= cratch, this time using scripts, so that your work is recorded and replayab= le.

David J.
--0000000000008f484d061aca9a88--