Sample Header Ad - 728x90

Get column names and data types of a query, table or view

34 votes
5 answers
175757 views
Is there a PostgreSQL query or command that returns the field names and field types of a query, table or view? E.g., a solution if applied to simple SELECT query like SELECT * from person should return a list like: Column Name | Column Type =========================== First Name | character Last Name | character Age | integer Date of Birth | date I have looked up the information_schema views described in an answer below and it seems to cover tables quite well, and I suspect it covers views as well but I haven't checked that yet. The last is any arbitrary but valid SELECT query eg involving, JOINS, UNIONS etc, on the database. Is there a built-in procedure, or other stored procedure or script that can return the same for any valid QUERY at all? I am developing a program that creates data and querying forms and the information is needed for data validation and executing functions on the returned data.
Asked by vfclists (1093 rep)
Aug 26, 2014, 10:46 PM
Last activity: Oct 29, 2024, 08:38 PM