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 1rb2lq-00ClH2-Ko for pgsql-general@arkaria.postgresql.org; Fri, 16 Feb 2024 18:17:11 +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 1rb2lp-003Lop-AQ for pgsql-general@arkaria.postgresql.org; Fri, 16 Feb 2024 18:17:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rb2ln-003Log-FX for pgsql-general@lists.postgresql.org; Fri, 16 Feb 2024 18:17:08 +0000 Received: from wfout8-smtp.messagingengine.com ([64.147.123.151]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rb2lk-0075W7-6x for pgsql-general@lists.postgresql.org; Fri, 16 Feb 2024 18:17:06 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.west.internal (Postfix) with ESMTP id 08A041C00076; Fri, 16 Feb 2024 13:17:01 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Fri, 16 Feb 2024 13:17:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1708107421; x=1708193821; bh=6NsMUZygAH mQ8xa+sJ2z8PJeNhYGZfY4db1xl6MfuTc=; b=SZhNaA+krjdDU29d+a2Vci3ILe IACCHsud0o6QcxD2TefDUBPTrg50XNubcJP5JdfdCUe44MbQTl60HQn1kkCeFL58 Keo+ZsjCbu8vmt4uBuZAHnQ+bjmGSGK5Lwe/c0ZB8t4/Va8g/5WK/S8bWWV33vo3 SNJOx+/tXiYa7m8Re1czpKT8HE6CXNqQ7T+AgeJvDzg8tHFrG1sTHDS99pn48WoC cq8sHOoY3dBvrNN+wum7DV89+RFIEiKhqDr5WrNaB7BZWoPK31kaWVtMDHxIEuwA MG5boS6aAhlqOKAonvaeyghua+wweNhKDoI97GqkP5sJXsAUMLxQDPC99+bA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708107421; x=1708193821; bh=6NsMUZygAHmQ8xa+sJ2z8PJeNhYG ZfY4db1xl6MfuTc=; b=C9Z8/7Iro42QSEK4y/Xw4R9mV0n2FHrJsAaUKQAbyrYA unGCOgFUzC0Rh51+X/TiIqfCMUa01+Px+Lz5IhCFqVg9nLs2TjMRRWyNshyAfW5Z vAmlxRJsBscIPjkDxUElNqZsIlLgEZwB0iK6pO5dJ1XmNra7Hmd7cFmiMgr2AsGL 5V2PKwHCUk7Ek8yyx8YIt++KqIo3yku1GZLFbDD7YQWP/UgQpB3P8r6sMX0vqBIh LlsuFcwMX3HgL0qzH4VG2svJfcssjgo8Z7VfRiJ4JoTdCv+5tV5bJsyeZpjpmkBC oJ1OoXiKuSflR0Bm9DaSSaFimE71zTknABNtDtpoww== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvgddutdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurheptgfkffggfgfuvfevfhfhjgesrgdtreertddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpedukeejgfdtfeekvefhueekvefhheefveefkeelvddv ffeukeekueeiieffudejteenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhi rghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 16 Feb 2024 13:17:00 -0500 (EST) Content-Type: multipart/alternative; boundary="------------LylSpkm6DZ10miXw8BGr003N" Message-ID: <640cdb04-d9a0-4ee1-8ae6-a13a29aafcac@aklaver.com> Date: Fri, 16 Feb 2024 10:16:58 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Identity and Sequence To: "David G. Johnston" , Michael Corey Cc: pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------LylSpkm6DZ10miXw8BGr003N Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2/16/24 10:10 AM, David G. Johnston wrote: > On Fri, Feb 16, 2024 at 10:24 AM Michael Corey > wrote: > > By explicitly making a column an IDENTITY column it is going to > make a sequence behind the scenes even if one with a similar name > exists.  I tried and it created part_tab_part_id_seq1.  Is there > no way to have it use the original part_tab_part_id_seq? > > > No, the fact that there is even a sequence is mostly an implementation > detail you shouldn't be concerned with. Actually you should be concerned with/aware of this detail for the reason you state below. > >  How do I get the data and the sequence in sync? > > > That would be why the alter table command has a bunch of keywords and > values as part of it.  So you can modify the values to be what you need. From https://www.postgresql.org/docs/current/sql-altertable.html " |SET /|sequence_option|/| |RESTART| These forms alter the sequence that underlies an existing identity column. /|sequence_option|/ is an option supported by |ALTER SEQUENCE| such as |INCREMENT BY|. " You need to know how a sequence works and what can be modified. > > David J. > -- Adrian Klaver adrian.klaver@aklaver.com --------------LylSpkm6DZ10miXw8BGr003N Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2/16/24 10:10 AM, David G. Johnston wrote:
On Fri, Feb 16, 2024 at 10:24 AM Michael Corey <michael.corey.ap@nielsen.com> wrote:
By explicitly making a column an IDENTITY column it is going to make a sequence behind the scenes even if one with a similar name exists.  I tried and it created part_tab_part_id_seq1.  Is there no way to have it use the original part_tab_part_id_seq?

No, the fact that there is even a sequence is mostly an implementation detail you shouldn't be concerned with.


Actually you should be concerned with/aware of this detail for the reason you state below.

 
 How do I get the data and the sequence in sync?  


That would be why the alter table command has a bunch of keywords and values as part of it.  So you can modify the values to be what you need.


From

https://www.postgresql.org/docs/current/sql-altertable.html

"

SET sequence_option
RESTART

These forms alter the sequence that underlies an existing identity column. sequence_option is an option supported by ALTER SEQUENCE such as INCREMENT BY.

"

You need to know how a sequence works and what can be modified.


David J.

-- 
Adrian Klaver
adrian.klaver@aklaver.com
--------------LylSpkm6DZ10miXw8BGr003N--