pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: stan <stanb@panix.com>
To: pgsql-general@postgresql.org
Subject: Query to get name a data type of a view
Date: Fri, 22 May 2020 11:11:15 -0400
Message-ID: <20200522151115.GA18237@panix.com> (raw)

When I run the following query,


SELECT column_name,data_type
FROM information_schema.columns
WHERE table_name = 'mfg_part_view';


I get the following result:

 column_name  |     data_type     
 --------------+-------------------
  mfg          | USER-DEFINED
  mfg_part_no  | character varying
  unit         | USER-DEFINED
  descrip      | character varying
  mfg_part_key | integer
(5 rows)

The SQL that creates this view is as follows:

CREATE VIEW mfg_part_view as
select
    mfg.name as mfg ,
	mfg_part.mfg_part_no ,
	costing_unit.unit ,
	mfg_part.descrip ,
	mfg_part.mfg_part_key
from mfg_part
right join costing_unit on
	mfg_part.unit_key = costing_unit.costing_unit_key
inner join mfg on
	mfg.mfg_key = mfg_part.mfg_key
WHERE mfg_part is NOT NULL
ORDER BY
	mfg.name ,
	mfg_part.mfg_part_no ;

Clearly that is not what I expected :-)

I need to return the name, and data type of each column for the specified
view. 

How can I do this?



-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin





view thread (2+ messages)  latest in thread

Message-ID: <20200522151115.GA18237@panix.com>
Permalink:  ../20200522151115.GA18237@panix.com/
Also on:    postgresql.org/message-id/20200522151115.GA18237@panix.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: stanb@panix.com
  Subject: Re: Query to get name a data type of a view
  In-Reply-To: <20200522151115.GA18237@panix.com>
  References: <20200522151115.GA18237@panix.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