Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go930-0007Cf-Ek for pgsql-general@arkaria.postgresql.org; Mon, 28 Jan 2019 15:42:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1go92z-0007h9-8R for pgsql-general@arkaria.postgresql.org; Mon, 28 Jan 2019 15:42:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go92y-0007h2-Tg for pgsql-general@lists.postgresql.org; Mon, 28 Jan 2019 15:42:05 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go92v-00071o-Nx for pgsql-general@lists.postgresql.org; Mon, 28 Jan 2019 15:42:03 +0000 Received: from [192.168.127.1] (port=17217 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1go92s-0002Is-JZ; Mon, 28 Jan 2019 15:41:58 +0000 Received: from [127.0.0.1] (port=18810 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1go92r-000FpZ-Nz; Mon, 28 Jan 2019 15:41:57 +0000 From: Andrew Gierth To: Susan Hurst Cc: Discuss List Postgres Subject: Re: Displaying Comments in Views In-Reply-To: <8d48b89ca871afcce64a6b78d2db2b0c@mail.brookhurstdata.net> (Susan Hurst's message of "Mon, 28 Jan 2019 09:08:13 -0600") Message-ID: <87lg34izi5.fsf@news-spur.riddles.org.uk> References: <8d48b89ca871afcce64a6b78d2db2b0c@mail.brookhurstdata.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Mon, 28 Jan 2019 15:41:56 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Susan" == Susan Hurst writes: Susan> What is the trick for displaying column comments in views? The Susan> query below works as expected when the table_schema includes Susan> tables, however it shows nothing when the table_schema contains Susan> only views. I tried putting the query into an inline statement Susan> as a column selection in a wrapper query...I got all the Susan> table/column data but the comment column values were all null. Susan> from pg_catalog.pg_statio_all_tables st That is the wrong place to look for the purposes of this query, since as the name implies it only shows tables (and not views, since non-materialized views don't have or need I/O statistics). Also, it's _NOT_ the place to look when you just want a list of tables in the db or to look up tables by oid; use pg_class for that. I'd have gone with something along the lines of: select n.nspname as table_schema, c.relname as table_name, a.attname as column_name, pd.description as description from pg_class c join pg_namespace n on (n.oid=c.relnamespace) join pg_attribute a on (a.attrelid=c.oid and a.attnum > 0 and not a.attisdropped) join pg_description pd on (pd.classoid='pg_class'::regclass and pd.objoid=c.oid and pd.objsubid=a.attnum) where n.nspname = 'devops' order by n.nspname, c.relname, a.attname; -- Andrew (irc:RhodiumToad)