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