473,508 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2590
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
6169
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
4087
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
1500
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
3706
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
1571
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
1297
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
1536
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
1877
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
5084
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
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.