From robins@pobox.com Mon Jun 1 08:15:54 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFGj5-00070A-Gh for pgsql-docs@arkaria.postgresql.org; Tue, 12 Mar 2013 04:22:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UFGj5-0005zy-1A for pgsql-docs@arkaria.postgresql.org; Tue, 12 Mar 2013 04:22:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFGj4-0005zt-Cj for pgsql-docs@postgresql.org; Tue, 12 Mar 2013 04:22:10 +0000 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFGj1-0000eA-1w for pgsql-docs@postgresql.org; Tue, 12 Mar 2013 04:22:09 +0000 Received: by mail-wi0-f182.google.com with SMTP id hi18so1486852wib.3 for ; Mon, 11 Mar 2013 21:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:sender:from:date:x-google-sender-auth :message-id:subject:to:content-type; bh=nsOkWhEkF7XWg2fooY2Szd5h30OPoA03RlC7l48fs+o=; b=QlwfWCHYotHxoq20PMw/1rh0fFBHPeKyBwDHRxsNMbj+wUFJ4upWhR3t+22kwtnIMK F9GXzsioo+bvMqzhQxfU63aMfkIhwXtRn9SvaBAMAQPK9kEXgVjW4gG41iWaGgidGApV Zirk5DvvvPe4edgL+GX7PBejRBVVSups/q0ZMFKj+dC1TXbnGkD82pzymyXXoI4vG0vz 9gDn0DdjJnzBs08ui1s89uFRXSkId0MHNjB/G4Jrnsx2eTDLEIxWof0ZcKLphaRoEiD4 BhYdy2hx/ocBwqPHznGhj7M9ICImF/ghcEzCgeOk/JgNsp2k8xtembOCvtLqx51mKpnd ZNmw== X-Received: by 10.181.12.5 with SMTP id em5mr16728024wid.24.1363062125805; Mon, 11 Mar 2013 21:22:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.13.227 with HTTP; Mon, 11 Mar 2013 21:21:44 -0700 (PDT) From: Robins Date: Tue, 12 Mar 2013 09:51:44 +0530 X-Google-Sender-Auth: nRGG2LaC6iK9HJdRfFUCvCM7Tqk Message-ID: Subject: Clarify 'dependent objects' for DROP COLUMN To: pgsql-docs@postgresql.org Content-Type: multipart/alternative; boundary=f46d043c7c58d0cae204d7b2a19a X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --f46d043c7c58d0cae204d7b2a19a Content-Type: text/plain; charset=ISO-8859-1 Hi, ALTER TABLE in postgresql.org/docs/devel/ says: RESTRICT: Refuse to drop the column or constraint if there are any dependent objects. This is the default behavior. Could someone confirm whether 'dependent objects' also includes SEQUENCES? i.e. if I create a sequence OWNED BY tbl.col1 and then try to drop the column with RESTRICT, should it allow this DROP? Currently it does, but by reading that line it seemed it shouldn't. Thanks --- Robins Tharakan --f46d043c7c58d0cae204d7b2a19a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
= Hi,
<= div class=3D"gmail_default">
ALTER TABLE in=A0postgresql.org/docs/devel/ says:

RESTRICT: Refuse to drop the column or constraint if there are any = dependent objects. This is the default behavior.

Could someone confirm whether 'dependent objects' also inclu= des SEQUENCES? i.e. if I create a sequence OWNED BY tbl.col1 and= then try to drop the column with RESTRICT, should it allow this DROP? Curr= ently it does, but by reading that line it seemed it shouldn't.<= /div>

T= hanks
---
Robins Tharakan
--f46d043c7c58d0cae204d7b2a19a-- From tharakan@gmail.com Mon Jun 1 08:15:55 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFHzR-0004dP-Rz for pgsql-docs@arkaria.postgresql.org; Tue, 12 Mar 2013 05:43:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UFHzR-0001dk-32 for pgsql-docs@arkaria.postgresql.org; Tue, 12 Mar 2013 05:43:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFHzQ-0001de-3I for pgsql-docs@postgresql.org; Tue, 12 Mar 2013 05:43:08 +0000 Received: from mail-wg0-f45.google.com ([74.125.82.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFHzL-0002jN-Qy for pgsql-docs@postgresql.org; Tue, 12 Mar 2013 05:43:05 +0000 Received: by mail-wg0-f45.google.com with SMTP id dq12so5893265wgb.24 for ; Mon, 11 Mar 2013 22:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=Kfi3wJB9btCLkkKhzKwioPMs9CqYNt7hdsdfxe0aicw=; b=HU7ybxGmmhLLfVfAlNInLcEkdBSA6kzj1atV63eaJtWjPohIYSW5iQGD4HXOM+fXEF LWFagqb2nAcF4+ZcbqYyll6ief4vZCbgrEAxpyEIPeGaFVfFgR3xoghm3ZlZVMcHBITX Sn21TXm8HwEdnQSuLXLpeCmAxHkm4pw4NB4F+mWfhKgwVgRVPZjrb6lEe8CID9c22mGl uNgrXQ0y+tv90S+VbjdQTTXm5TM+D5df+O/pqSeEpZSsAclp8rbcOzOuH4MzKX5tvsCU Jh8Orjk9lRd1K9EZWNmBwi+jRqJhoGyuDpPqFT+TvM4cTn3yB6af1tUC+Mziy8ubs8dh P8nQ== X-Received: by 10.180.183.4 with SMTP id ei4mr16787898wic.21.1363066982756; Mon, 11 Mar 2013 22:43:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.13.227 with HTTP; Mon, 11 Mar 2013 22:42:42 -0700 (PDT) From: robins Date: Tue, 12 Mar 2013 11:12:42 +0530 Message-ID: Subject: Clarify 'dependent objects' for DROP COLUMN To: pgsql-docs@postgresql.org Content-Type: multipart/alternative; boundary=001a11c22a2e4ff85004d7b3c3d7 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --001a11c22a2e4ff85004d7b3c3d7 Content-Type: text/plain; charset=ISO-8859-1 Hi, ALTER TABLE in postgresql.org/docs/devel/ says: RESTRICT: Refuse to drop the column or constraint if there are any dependent objects. This is the default behavior. Could someone confirm whether 'dependent objects' also includes SEQUENCES? i.e. if I create a sequence OWNED BY tbl.col1 and then try to drop the column with RESTRICT, should it allow this DROP? Currently it does, but by reading that line it seemed it shouldn't. Thanks -- Robins Tharakan p.s.: Had to re-post this. Apologies if this lands up twice in the queue. --001a11c22a2e4ff85004d7b3c3d7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi,
<= div class=3D"gmail_default" style=3D"color:rgb(34,34,34);font-family:arial,= sans-serif;font-size:13px">
ALTER TABLE in=A0postgresql.org/docs/devel/=A0says:

RESTRICT: Ref= use to drop the column or constraint if there are any dependent objects. Th= is is the default behavior.

=
Could someone confirm whether '= dependent objects' also includes SEQUENCES?=A0i.e. if I create a sequence OWN= ED BY tbl.col1 and then try to drop the column with RESTRICT, should it all= ow this DROP? Currently it does, but by reading that line it seemed it shou= ldn't.

Thanks
--
Robi= ns Tharakan
p.s.: Had to re-post this. Apologies if this la= nds up twice in the queue.
--001a11c22a2e4ff85004d7b3c3d7-- From bruce@momjian.us Mon Jun 1 08:15:54 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFt5S-0005ft-3u for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 21:19:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UFt5R-0001h3-Iu for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 21:19:49 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFt5Q-0001gE-GO for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 21:19:48 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFt5M-0007Fm-9c for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 21:19:47 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1UFt5J-0007yY-JY; Wed, 13 Mar 2013 17:19:41 -0400 Date: Wed, 13 Mar 2013 17:19:41 -0400 From: Bruce Momjian To: Robins Cc: pgsql-docs@postgresql.org Subject: Re: Clarify 'dependent objects' for DROP COLUMN Message-ID: <20130313211941.GB22282@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org On Tue, Mar 12, 2013 at 09:51:44AM +0530, Robins wrote: > Hi, > > ALTER TABLE in postgresql.org/docs/devel/ says: > > RESTRICT: Refuse to drop the column or constraint if there are any dependent > objects. This is the default behavior. > > Could someone confirm whether 'dependent objects' also includes SEQUENCES? i.e. > if I create a sequence OWNED BY tbl.col1 and then try to drop the column with > RESTRICT, should it allow this DROP? Currently it does, but by reading that > line it seemed it shouldn't. I had to dig a little bit on this. The "dependent" object would be the removal of the constraint depending on the sequence. Here is an example: test=> create table test (x serial); CREATE TABLE test=> \d test Table "public.test" Column | Type | Modifiers --------+---------+-------------------------------------------------- x | integer | not null default nextval('test_x_seq'::regclass) test=> \ds List of relations Schema | Name | Type | Owner --------+------------+----------+---------- public | test_x_seq | sequence | postgres (1 row) --> test=> drop sequence test_x_seq; ERROR: cannot drop sequence test_x_seq because other objects depend on it DETAIL: default for table test column x depends on sequence test_x_seq HINT: Use DROP ... CASCADE to drop the dependent objects too. --> test=> drop sequence test_x_seq cascade; NOTICE: drop cascades to default for table test column x DROP SEQUENCE test=> \d test Table "public.test" Column | Type | Modifiers --------+---------+----------- x | integer | not null If this does not answer your questions, please post queries showing the problem. Thanks. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs From tharakan@gmail.com Mon Jun 1 08:15:54 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFtr8-0001Zt-JI for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 22:09:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UFtr8-0007HZ-3n for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 22:09:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFtr7-0007HU-Ei for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 22:09:05 +0000 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFtr5-0008Ql-9C for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 22:09:05 +0000 Received: by mail-wg0-f42.google.com with SMTP id 12so442912wgh.5 for ; Wed, 13 Mar 2013 15:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=0f/+qEUr43dVAc9dD8uXrp8DAZp7WZrzxI0iiuQ/t+U=; b=UI2MXqoAkOOZ0OK45jVMSBipVNuvjE4G+HSDWfnbWlZ/jlcdEVg+W38U/gRbP4pzXn tEyIqsriEPJwkXYapTHXdTwo2NrJHaFYwe6zGp0wHuG6TcZ2ccbJZ8JivjsTTNhxjx8i /Av0p8QEA0EGq+AAJncrVQgteCks3grz4jYxNPdx8Kf5Q21rAFxUZwm3j133OB5b9CEi 6grWJWXfkGH1pk4KsWQMvIEsM+1XlKh5n57fb9TXa5VikCTodkzLeQdGhuB8gGSfNEH9 oOR4YG5IfFPJQxBF9DsRSqvxi1WC7XRSNlgePHMHjjIiejmW91pxGRhTdL4wCWAnYHe8 I8GQ== X-Received: by 10.194.62.170 with SMTP id z10mr37240377wjr.34.1363212542868; Wed, 13 Mar 2013 15:09:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.13.227 with HTTP; Wed, 13 Mar 2013 15:08:42 -0700 (PDT) In-Reply-To: <20130313211941.GB22282@momjian.us> References: <20130313211941.GB22282@momjian.us> From: robins Date: Thu, 14 Mar 2013 03:38:42 +0530 Message-ID: Subject: Re: Clarify 'dependent objects' for DROP COLUMN To: pgsql-docs@postgresql.org Content-Type: multipart/alternative; boundary=047d7ba983025f056a04d7d5a77b X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --047d7ba983025f056a04d7d5a77b Content-Type: text/plain; charset=ISO-8859-1 Thanks Bruce. I think by using the word 'constraint' I understand what the documentation meant. Both my queries (samples given below) arose from the fact that although there was a 'relation', this is probably not what the documentation was talking about. Q1: postgres=# CREATE TABLE serialTest3 (f1 bigint); CREATE TABLE postgres=# CREATE SEQUENCE seq4 OWNED BY serialTest3.f1; CREATE SEQUENCE postgres=# DROP SEQUENCE seq4; DROP SEQUENCE postgres=# Q2: postgres=# CREATE TABLE serialTest3 (f1 bigint); CREATE TABLE postgres=# CREATE SEQUENCE seq4 OWNED BY serialTest3.f1; CREATE SEQUENCE postgres=# ALTER TABLE serialTest3 DROP COLUMN f1 RESTRICT; ALTER TABLE postgres=# I was working on some regression tests and then just wanted to be sure that this (Q2 in particular) was perfectly legal, before adding checks for them. Thanks again. -- Robins Tharakan ---------- Forwarded message ---------- I had to dig a little bit on this. The "dependent" object would be the removal of the constraint depending on the sequence. Here is an example: test=> create table test (x serial); CREATE TABLE test=> \d test Table "public.test" Column | Type | Modifiers --------+---------+-------------------------------------------------- x | integer | not null default nextval('test_x_seq'::regclass) test=> \ds List of relations Schema | Name | Type | Owner --------+------------+----------+---------- public | test_x_seq | sequence | postgres (1 row) --> test=> drop sequence test_x_seq; ERROR: cannot drop sequence test_x_seq because other objects depend on it DETAIL: default for table test column x depends on sequence test_x_seq HINT: Use DROP ... CASCADE to drop the dependent objects too. --> test=> drop sequence test_x_seq cascade; NOTICE: drop cascades to default for table test column x DROP SEQUENCE test=> \d test Table "public.test" Column | Type | Modifiers --------+---------+----------- x | integer | not null If this does not answer your questions, please post queries showing the problem. Thanks. --047d7ba983025f056a04d7d5a77b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks Bruce.

I think by using the w= ord 'constraint' I understand what the documentation meant.=A0

Both my queries (sampl= es given below) arose from the fact that although there was a 'relation= ', this is probably not what the documentation was talking about.

Q1:
postgres=3D# CREATE TABLE= serialTest3 (f1 bigint);
CREATE TABLE
postgres=3D# CREATE SEQUENCE seq4 OWNED BY serialTest3.f1;
CREATE SEQUENCE
postgres=3D# DROP SEQUENCE seq4;
DROP S= EQUENCE
postgres=3D#=A0


Q2:
postgres=3D# CREATE TABLE seria= lTest3 (f1 bigint);
CREATE TABLE
postgres=3D# CREA= TE SEQUENCE seq4 OWNED BY serialTest3.f1;
CREATE SEQUENCE
postgres=3D# ALTER TABLE serialTest3 DROP COLUMN f1 RESTRICT;
ALTER TABLE
postgres=3D#=A0

I was working on some regression tests and the= n just wanted to be sure that this (Q2 in particular) was perfectly legal, = before adding checks for them.

Thanks again.
--
Robins
Thar= akan


---------- Forwarded message ----------<= div class=3D"">

I had to dig a little bit on this. =A0The "dependent"= object would be the
removal of the constraint depending on the sequence. =A0Here is an
example:

=A0 =A0 =A0 =A0 test=3D> create table test (x serial);
=A0 =A0 =A0 =A0 CREATE TABLE
=A0 =A0 =A0 =A0 test=3D> \d test
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Table &q= uot;public.test"
=A0 =A0 =A0 =A0 =A0Column | =A0Type =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0Modifiers
=A0 =A0 =A0 =A0 --------+---------+----------------------------------------= ----------
=A0 =A0 =A0 =A0 =A0x =A0 =A0 =A0| integer | not null default nextval('t= est_x_seq'::regclass)

=A0 =A0 =A0 =A0 test=3D> \ds
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0List of relations
=A0 =A0 =A0 =A0 =A0Schema | =A0 =A0Name =A0 =A0| =A0 Type =A0 | =A0Owner =A0 =A0 =A0 =A0 --------+------------+----------+----------
=A0 =A0 =A0 =A0 =A0public | test_x_seq | sequence | postgres
=A0 =A0 =A0 =A0 (1 row)

--> =A0 =A0 test=3D> drop sequence test_x_seq;
=A0 =A0 =A0 =A0 ERROR: =A0cannot drop sequence test_x_seq because other obj= ects depend on it
=A0 =A0 =A0 =A0 DETAIL: =A0default for table test column x depends on seque= nce test_x_seq
=A0 =A0 =A0 =A0 HINT: =A0Use DROP ... CASCADE to drop the dependent objects= too.
--> =A0 =A0 test=3D> drop sequence test_x_seq cascade;
=A0 =A0 =A0 =A0 NOTICE: =A0drop cascades to default for table test column x=
=A0 =A0 =A0 =A0 DROP SEQUENCE
=A0 =A0 =A0 =A0 test=3D> \d test
=A0 =A0 =A0 =A0 =A0 =A0 =A0Table "public.test"
=A0 =A0 =A0 =A0 =A0Column | =A0Type =A0 | Modifiers
=A0 =A0 =A0 =A0 --------+---------+-----------
=A0 =A0 =A0 =A0 =A0x =A0 =A0 =A0| integer | not null

If this does not answer your questions, please post queries showing the
problem. =A0 Thanks.
--047d7ba983025f056a04d7d5a77b-- From bruce@momjian.us Mon Jun 1 08:15:54 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFuMm-0004iq-LB for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 22:41:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UFuMm-00021y-09 for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 22:41:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFuMl-00021s-88 for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 22:41:47 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFuMh-0000WL-DX for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 22:41:45 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1UFuMg-0002JL-J9; Wed, 13 Mar 2013 18:41:42 -0400 Date: Wed, 13 Mar 2013 18:41:42 -0400 From: Bruce Momjian To: robins Cc: pgsql-docs@postgresql.org Subject: Re: Clarify 'dependent objects' for DROP COLUMN Message-ID: <20130313224142.GE22282@momjian.us> References: <20130313211941.GB22282@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org On Thu, Mar 14, 2013 at 03:38:42AM +0530, robins wrote: > Thanks Bruce. > > I think by using the word 'constraint' I understand what the documentation > meant. > > Both my queries (samples given below) arose from the fact that although there > was a 'relation', this is probably not what the documentation was talking > about. > > Q1: > postgres=# CREATE TABLE serialTest3 (f1 bigint); > CREATE TABLE > postgres=# CREATE SEQUENCE seq4 OWNED BY serialTest3.f1; > CREATE SEQUENCE > postgres=# DROP SEQUENCE seq4; > DROP SEQUENCE > postgres=# > > > Q2: > postgres=# CREATE TABLE serialTest3 (f1 bigint); > CREATE TABLE > postgres=# CREATE SEQUENCE seq4 OWNED BY serialTest3.f1; > CREATE SEQUENCE > postgres=# ALTER TABLE serialTest3 DROP COLUMN f1 RESTRICT; > ALTER TABLE > postgres=# > > I was working on some regression tests and then just wanted to be sure that > this (Q2 in particular) was perfectly legal, before adding checks for them. It seems like the OWNED BY only handles auto-drop, rather than sequence removal restrictions: The OWNED BY option causes the sequence to be associated with a specific table column, such that if that column (or its whole table) is dropped, the sequence will be automatically dropped as well. The specified table must have the same owner and be in the same schema as the sequence. OWNED BY NONE, the default, specifies that there is no such association. Seems it is not the same as actually referencing the sequence in the table. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs