473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

SQL text of view

Hi.

Where is the SQL text of view stored in the database?
I mean the text like "SELECT the_field FROM the_table".
I can found the function's text in "pg_proc.proerc", but can't find the same
for a view.

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

http://archives.postgresql.org

Nov 12 '05 #1
2 2581
Yury Shvetsov wrote:
Hi.

Where is the SQL text of view stored in the database?
I mean the text like "SELECT the_field FROM the_table".
I can found the function's text in "pg_proc.proerc", but can't find the same
for a view.


You can use the function pg_get_viewdef() in 7.3 to get the text of
the view. If you start psql with the -E switch you can see the queries
it uses to render its output.

When you create a view, an ON SELECT rewrite rule is automatically
created and its parse tree is stored in pg_rewrite. pg_get_viewdef()
is ultimately executing:

SELECT *
FROM pg_catalog.pg_rewrite
WHERE ev_class = <your view's pg_class.oid> AND
rulename = '_RETURN';

and reverse-parsing the stored parse tree for you.

HTH,

Mike Mascari
ma*****@mascari.com

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

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #2
Yury Shvetsov schrieb:
Hi.

Where is the SQL text of view stored in the database?
I mean the text like "SELECT the_field FROM the_table".
I can found the function's text in "pg_proc.proerc", but can't find the same
for a view.

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

http://archives.postgresql.org

What about

SELECT definition
FROM pg_views
WHERE viewname = <name of view>

Thomas

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
5
by: Joe Patrick | last post by:
On my websites index.html page I have this script: <SCRIPT language="JavaScript"> <!-- // if ((screen.width==1024) && (screen.height==768)) { document.write('<a href="active.html">Click here</a>...
1
by: Douglas Pollock | last post by:
I've been trying to use HTML text that will scale up or down using the Internet Explorer 6.0 menu View\Text Size. I'm using CSS to set the sizes and weight. When I use View\Text Size Medium and...
1
by: ing42 | last post by:
I have a problem with inserting records into table when an indexed view is based on it. Table has text field (without it there is no problem, but I need it). Here is a sample code: USE test GO...
0
by: Raziq Shekha | last post by:
What is the procedure to create a full text index on a view? I created full text indexes on the underlying tables for a view, but when the query is run against the view I am getting the errror...
0
by: coosa | last post by:
Dear all, I'm using MS SQL Server 2005 and i have a full-text search issue; Let's say i have table1, table2 and table 3; for each, some full-text indices have been created. The issue is that i...
3
by: settyv | last post by:
Hi, I need to generate PDF stream when i click on Linkbutton in datagrid ..At present i hardcoded the DMS Id and now it is working.But i need to pass DMS ID when click linkbutton.How can i do...
7
by: Lazoris | last post by:
Ok Mods got another test for ya.. Since I know you are good at this stuff maybe you can help me out again.. I started getting my pages the way I wanted them to look last weekend, and got pretty...
8
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.