how to get the source table & field name of a view field

how to get the source table & field name of a view field

Post by Prime H » Fri, 08 Nov 2002 18:12:20



Hi,

Could you tell me how to get view field's source table and field name?
another word, how could I know the view field come from?

Regards,
Ho

 
 
 

how to get the source table & field name of a view field

Post by Christoph Hall » Sat, 09 Nov 2002 00:02:42


Quote:> Could you tell me how to get view field's source table and field name?
> another word, how could I know the view field come from?

Within psql, use
\d <viewname>
to learn about the view's column names and types and the view
definition.

If you were thinking about querying system tables to get this
information,
start psql with the "-E" option to see how this \d <viewname> command
is implemented.

Regards, Christoph

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

 
 
 

how to get the source table & field name of a view field

Post by Achilleus Mantzi » Sat, 09 Nov 2002 00:37:20



> Hi,

> Could you tell me how to get view field's source table and field name?
> another word, how could I know the view field come from?

SELECT definition from pg_views where viewname='<your view name>';

> Regards,
> Ho

> ---------------------------(end of broadcast)---------------------------


==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-10-8981112
fax:    +30-10-8981877


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

 
 
 

how to get the source table & field name of a view field

Post by Ken Kenne » Sat, 09 Nov 2002 00:56:24



> Hi,

> Could you tell me how to get view field's source table and field name?
> another word, how could I know the view field come from?

\d view_name should give you the view definition in pqsl.

--


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

 
 
 

how to get the source table & field name of a view field

Post by Christoph Hall » Sat, 09 Nov 2002 17:22:45


Quote:

> if I want to write a function for getting the view.field's source
> table.field
> how could I achieve it?

This sounds like a real challange.
Throughout the years I've had to learn it's always a pain to
retrieve system catalog information - no matter which
DBMS is in use.
On the other hand, you have to face the fact that
view.field's sources are not necessarily directly derived
from a table.field.
A view.field's source may be any expression including aggregates.

So, the only way I can think of achieving that is

SELECT definition from pg_views where viewname='<your view name>';

and then your function has to parse the result. Good luck.

Regards, Christoph

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

 
 
 

1. get source table.field name from view's field

Hi,
Firstly , sorry about my poor english, I'll do my best to explain what I
want.
Actually, in most cases, We do query via view, in order to improve
the query speed, we'll create index in physical table field that is mapped
in view's where statement. So, I got an idea to store view statement in a
DataDictionay,
while I maintain the DataDictionary's sql statement, program will trigger a
function
to  parse the sql statement, and create index in relative table field
automatically.
So, the problem is how to get the source table & field name for create
index,
could it achieve by oid or postgresql already have function to do that?

Regards,
Ho.

2. Announce: PCA 2

3. How do I extract ONE particular field, when multiple table contain the same field name?

4. Are we using Synopsys multicycle paths unsafely?

5. loosing acroform fields when view Windows/Fields

6. Good Quotes (OcINpO)

7. Evaluating a field containing a field name

8. Speed problem with Matlab 6

9. import with field names because fields wrong order

10. Create table fields as sum of two other fields.

11. Need QBE-style tool to build SQL views (tables with computed fields)

12. What is the best way to get all user defined field names in a table?

13. View Custom Fields with a View in a Custom Template