Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpxcU-0006U6-QG for pgsql-performance@arkaria.postgresql.org; Mon, 20 Mar 2017 13:45:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cpxcU-0005R2-DG for pgsql-performance@arkaria.postgresql.org; Mon, 20 Mar 2017 13:45:10 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cpxah-00085k-K5; Mon, 20 Mar 2017 13:43:19 +0000 Received: from pb-smtp2.pobox.com ([64.147.108.71] helo=sasl.smtp.pobox.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cpxae-0003CM-E5; Mon, 20 Mar 2017 13:43:17 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id AE4C177A7D; Mon, 20 Mar 2017 09:43:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=subject:to :references:cc:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=sasl; bh=9gT8UTle5hHl 1fT6koxNq/JJ8X0=; b=vY7m/2nzTjeDaRbK935ZhR5qPxklrvKxMkcn1yKxizfH DvyV+NvBhXwK2OJmNxqL5g/8J18fNhamxZohWPxLrG3xSIUI/vGyG2Od79FGhuXE Nr2c5Dt/JIB+RwTmoaVMprnhekh90S/T3Ag7cwRl2GsEk00DHdmhpQFtmaMATh8= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id A681477A7C; Mon, 20 Mar 2017 09:43:13 -0400 (EDT) Received: from redhat.com (unknown [64.134.65.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 104F377A7B; Mon, 20 Mar 2017 09:43:13 -0400 (EDT) Subject: Re: Auto generate number in Postgres-9.1. To: Dinesh Chandra 12108 , "pgsql-performance-owner@postgresql.org" References: Cc: "pgsql-performance@postgresql.org" From: Josh Berkus Message-ID: <97da050c-395c-7205-c5e9-95e7fdf13fde@berkus.org> Date: Mon, 20 Mar 2017 09:43:11 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 X-Pobox-Relay-ID: 29CEDDE8-0D73-11E7-9AED-FC50AE2156B6-30013111!pb-smtp2.pobox.com DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=berkus.org; h=subject:to:references:cc:from:message-id:date:mime-version:in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=ViYRhhNWJL04Sm3/d9CzjkdqLkg=; b=S7uj6idxSIpgz7yAu1/c/L9FXGV9BdybzF7Kof55iZ+9pJZAzw/ZBHb2yFRc8pErB6xPftbVaFaXhQQOPFwHPezpxnE0wt00s6teurTDcKa/Pz8oGZx05e+QPdt51odSjzS67QTQ97KhFSLV0XNjg1SDjMzd8P09obXOfDdhOC4= Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Dinesh, > I have to add one column =93ID=94 in postgres table which will generate > Auto Increment > ed number= . >=20 >=20=20 >=20 > Example: >=20 > Suppose I have five records and if I insert 1 new record It should auto > generate 6. https://www.postgresql.org/docs/9.6/static/sql-createsequence.html also SERIAL on this page: https://www.postgresql.org/docs/9.6/static/datatype-numeric.html >=20 > If I truncate the same table and then again insert rows should start > with 1 in =93ID=94 column. That's not how it works, normally. I'd suggest adding an ON TRUNCATE trigger to the table. --=20 Josh Berkus Containers & Databases Oh My! --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance