Re: Get original view definition without modification

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: shandeep2846(at)gmail(dot)com
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Get original view definition without modification
Date: 2020-05-29 15:06:42
Message-ID: 10395.1590764802@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

PG Doc comments form <noreply(at)postgresql(dot)org> writes:
> I am looking a way to get exact view definition, for ex :
> ...
> I am fine with adding tablename before columnname but i don't want the extra
> '::text' part. Is there anyway to achieve this(like any other system table i
> can query from to get original definition)

No, Postgres only saves a "compiled" form of a view. Storing the original
text would have its own pitfalls, eg what if you rename a table or column
mentioned in the view? (Also, the SQL standard has some requirements that
would be difficult to meet otherwise.)

If you really want the original text, best bet is to keep your schema
creation commands in a VCS or the like, outside the database.

regards, tom lane

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2020-05-30 17:17:45 Minor result error in binary strings documentation
Previous Message p.luzanov 2020-05-29 12:59:02 Re: max_wal_size