pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Vitaly Burovoy <vitaly.burovoy@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: identity columns
Date: Wed, 22 Mar 2017 08:45:50 -0400
Message-ID: <c05eefac-0b55-74df-6343-71d232c15bc5@2ndquadrant.com> (raw )
In-Reply-To: <CAKOSWNnXmM6YBXNzGnXtZQMPjDgJF+a3Wx53Wzmrq5wqDyRX7Q@mail.gmail.com >
References: <6adbacbf-73bc-dd1a-2033-63409180fd18@2ndquadrant.com >
<CAKOSWNk3Ug6CV5RBPhF1UCiaR32ZTxdtf-iZ+uv6C3rP6cN8QA@mail.gmail.com >
<CAKOSWNkKUAb1qwubq+MhxbEyT0ewM2NYsXKUskxheg_dUWnWPw@mail.gmail.com >
<4ef801f2-64ce-1a58-277d-d9389ae7770d@2ndquadrant.com >
<e287f723-d095-0d24-483a-3b7e3611c3e9@2ndquadrant.com >
<CAKOSWNmsci7jZzpoqWAH_QcVjQzwOMf04o91Jf5WVTkHbDMy2w@mail.gmail.com >
<1cf308b6-4f5c-05ba-cc74-0a7121603fcf@2ndquadrant.com >
<CAKOSWNmKbthEdV0m1J=V7r6nDyPk8diKwHW93jYbB+wnXd-c1A@mail.gmail.com >
<ed41b243-63b2-f287-e7b0-8b2ac7266d66@2ndquadrant.com >
<CAKOSWNnMp0sKZzcX0zSKJOTSb1Fas02+xTW=kvGMu2NhRiOAbg@mail.gmail.com >
<ec772da8-3443-b39d-e25e-138ef01a71c1@2ndquadrant.com >
<CAKOSWNnXmM6YBXNzGnXtZQMPjDgJF+a3Wx53Wzmrq5wqDyRX7Q@mail.gmail.com >
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 3/22/17 03:59, Vitaly Burovoy wrote:
> Column's IDENTITY behavior is very similar to a DEFAULT one. We write
> "SET DEFAULT" and don't care whether it was set before or not, because
> we can't have many of them for a single column. Why should we do that
> for IDENTITY?
One indication is that the SQL standard requires that DROP IDENTITY only
succeed if the column is currently an identity column. That is
different from how DEFAULT works.
Another difference is that there is no such thing as "no default",
because in absence of an explicit default, it is NULL. So all you are
doing with SET DEFAULT or DROP DEFAULT is changing the default. You are
not actually adding or removing it.
Therefore, the final effect of SET DEFAULT is the same no matter whether
another default was there before or not. For ADD/SET IDENTITY, you get
different behaviors. For example:
ADD .. AS IDENTITY (START 2)
creates a new sequence that starts at 2 and uses default parameters
otherwise. But
SET (START 2)
alters the start parameter of an existing sequence. So depending on
whether you already have an identity sequence, these commands do
completely different things.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
view thread (55+ messages) latest in thread
Message-ID: <c05eefac-0b55-74df-6343-71d232c15bc5@2ndquadrant.com>
Permalink: ../c05eefac-0b55-74df-6343-71d232c15bc5@2ndquadrant.com/
Also on: postgresql.org/message-id/c05eefac-0b55-74df-6343-71d232c15bc5@2ndquadrant.com
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, vitaly.burovoy@gmail.com
Subject: Re: identity columns
In-Reply-To: <c05eefac-0b55-74df-6343-71d232c15bc5@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox