pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Query to get name a data type of a view
2+ messages / 2 participants
[nested] [flat]

* Query to get name a data type of a view
@ 2020-05-22 15:11 stan <stanb@panix.com>
  2020-05-22 15:16 ` Re: Query to get name a data type of a view David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: stan @ 2020-05-22 15:11 UTC (permalink / raw)
  To: pgsql-general

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Query to get name a data type of a view
  2020-05-22 15:11 Query to get name a data type of a view stan <stanb@panix.com>
@ 2020-05-22 15:16 ` David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: David G. Johnston @ 2020-05-22 15:16 UTC (permalink / raw)
  To: stan <stanb@panix.com>; +Cc: pgsql-general

On Friday, May 22, 2020, stan <stanb@panix.com> wrote:

> 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
>
>
> I need to return the name, and data type of each column for the specified
> view.
>

Use the pg_catalog schema “tables” directly instead of the SQL standard
information_schema view.  The later doesn’t provide detail of
PostgreSQL-specific features by definition.

David J.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-05-22 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 15:11 Query to get name a data type of a view stan <stanb@panix.com>
2020-05-22 15:16 ` David G. Johnston <david.g.johnston@gmail.com>

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