Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7e1m-0000Zs-6a for pgsql-sql@arkaria.postgresql.org; Mon, 27 Jan 2014 04:42:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W7e1k-0003aw-AD for pgsql-sql@arkaria.postgresql.org; Mon, 27 Jan 2014 04:42:28 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7e1j-0003ap-7Y for pgsql-sql@postgresql.org; Mon, 27 Jan 2014 04:42:27 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7e1b-0008MU-Tn for pgsql-sql@postgresql.org; Mon, 27 Jan 2014 04:42:26 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W7e1Z-0007Rn-BJ for pgsql-sql@postgresql.org; Mon, 27 Jan 2014 05:42:17 +0100 Received: from e177173254.adsl.alicedsl.de ([85.177.173.254]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Jan 2014 05:42:17 +0100 Received: from tim by e177173254.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Jan 2014 05:42:17 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org From: Tim Landscheidt Subject: Re: find all views depend on a schema/table Date: Mon, 27 Jan 2014 04:42:06 +0000 Organization: http://www.tim-landscheidt.de/ Lines: 33 Message-ID: <87k3dmrq75.fsf@passepartout.tim-landscheidt.de> References: <52E28D0D.3080908@encs.concordia.ca> <13660.1390580600@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e177173254.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:PQAszGBQfSh+KWU80PQnmSoV3OM= X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Tom Lane wrote: >> Is there a simple way to query all views depend on a schema or table? > Well, you could build something that examines pg_depend, or you could > try this: > begin; > drop table some_table restrict; > ... note what it complains about ... > rollback; Note that neither show dependencies that are "hidden" in functions, i. e.: | tim=# CREATE TABLE T (ID INT PRIMARY KEY); | NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t_pkey" for table "t" | CREATE TABLE | tim=# CREATE FUNCTION F() RETURNS INT AS 'SELECT MIN(ID) FROM T;' LANGUAGE SQL; | CREATE FUNCTION | tim=# CREATE VIEW V AS SELECT F(); | CREATE VIEW | tim=# DROP TABLE T; | DROP TABLE | tim=# SELECT * FROM V; | ERROR: relation "t" does not exist | LINE 1: SELECT MIN(ID) FROM T; | ^ | QUERY: SELECT MIN(ID) FROM T; | CONTEXT: SQL function "f" during inlining | tim=# Tim -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql