dbTalk Databases Forums  

Fetch table names from query

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Fetch table names from query in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default Fetch table names from query - 05-20-2008 , 06:48 AM






Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--

Reply With Quote
  #2  
Old   
DA Morgan
 
Posts: n/a

Default Re: Fetch table names from query - 05-21-2008 , 11:25 AM






Álvaro G. Vicario wrote:
Quote:
Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,
This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

For example I have organizations here in the US that are, by law,
required to keep data online for 7 years. It hopefully will never be
accessed. But on audit, if it isn't there, they are in a boatload of
trouble.

This is a really bad idea, for many reasons, you should drop
immediately. Leave managing the database to the database professionals.
It is not something someone writing PHP should involve themselves in.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #3  
Old   
DA Morgan
 
Posts: n/a

Default Re: Fetch table names from query - 05-21-2008 , 11:25 AM



Álvaro G. Vicario wrote:
Quote:
Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,
This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

For example I have organizations here in the US that are, by law,
required to keep data online for 7 years. It hopefully will never be
accessed. But on audit, if it isn't there, they are in a boatload of
trouble.

This is a really bad idea, for many reasons, you should drop
immediately. Leave managing the database to the database professionals.
It is not something someone writing PHP should involve themselves in.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #4  
Old   
DA Morgan
 
Posts: n/a

Default Re: Fetch table names from query - 05-21-2008 , 11:25 AM



Álvaro G. Vicario wrote:
Quote:
Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,
This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

For example I have organizations here in the US that are, by law,
required to keep data online for 7 years. It hopefully will never be
accessed. But on audit, if it isn't there, they are in a boatload of
trouble.

This is a really bad idea, for many reasons, you should drop
immediately. Leave managing the database to the database professionals.
It is not something someone writing PHP should involve themselves in.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #5  
Old   
DA Morgan
 
Posts: n/a

Default Re: Fetch table names from query - 05-21-2008 , 11:25 AM



Álvaro G. Vicario wrote:
Quote:
Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,
This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

For example I have organizations here in the US that are, by law,
required to keep data online for 7 years. It hopefully will never be
accessed. But on audit, if it isn't there, they are in a boatload of
trouble.

This is a really bad idea, for many reasons, you should drop
immediately. Leave managing the database to the database professionals.
It is not something someone writing PHP should involve themselves in.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #6  
Old   
Dan Blum
 
Posts: n/a

Default Re: Fetch table names from query - 05-21-2008 , 01:59 PM



DA Morgan <damorgan (AT) psoug (DOT) org> wrote:
Quote:
?lvaro G. Vicario wrote:
Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,

This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

For example I have organizations here in the US that are, by law,
required to keep data online for 7 years. It hopefully will never be
accessed. But on audit, if it isn't there, they are in a boatload of
trouble.

This is a really bad idea, for many reasons, you should drop
immediately. Leave managing the database to the database professionals.
It is not something someone writing PHP should involve themselves in.
I think he means he wants to identify obsolete data in his results cache,
so he can refresh it from the database, not delete data from the database.

However, I agree that this is not a wonderful idea, as it is essentially
recreating Oracle functionality. If results caching is that critical,
I would suggest running 11g, which implements it.

--
__________________________________________________ _____________________
Dan Blum tool (AT) panix (DOT) com
"I wouldn't have believed it myself if I hadn't just made it up."


Reply With Quote
  #7  
Old   
Dan Blum
 
Posts: n/a

Default Re: Fetch table names from query - 05-21-2008 , 01:59 PM



DA Morgan <damorgan (AT) psoug (DOT) org> wrote:
Quote:
?lvaro G. Vicario wrote:
Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,

This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

For example I have organizations here in the US that are, by law,
required to keep data online for 7 years. It hopefully will never be
accessed. But on audit, if it isn't there, they are in a boatload of
trouble.

This is a really bad idea, for many reasons, you should drop
immediately. Leave managing the database to the database professionals.
It is not something someone writing PHP should involve themselves in.
I think he means he wants to identify obsolete data in his results cache,
so he can refresh it from the database, not delete data from the database.

However, I agree that this is not a wonderful idea, as it is essentially
recreating Oracle functionality. If results caching is that critical,
I would suggest running 11g, which implements it.

--
__________________________________________________ _____________________
Dan Blum tool (AT) panix (DOT) com
"I wouldn't have believed it myself if I hadn't just made it up."


Reply With Quote
  #8  
Old   
Dan Blum
 
Posts: n/a

Default Re: Fetch table names from query - 05-21-2008 , 01:59 PM



DA Morgan <damorgan (AT) psoug (DOT) org> wrote:
Quote:
?lvaro G. Vicario wrote:
Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,

This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

For example I have organizations here in the US that are, by law,
required to keep data online for 7 years. It hopefully will never be
accessed. But on audit, if it isn't there, they are in a boatload of
trouble.

This is a really bad idea, for many reasons, you should drop
immediately. Leave managing the database to the database professionals.
It is not something someone writing PHP should involve themselves in.
I think he means he wants to identify obsolete data in his results cache,
so he can refresh it from the database, not delete data from the database.

However, I agree that this is not a wonderful idea, as it is essentially
recreating Oracle functionality. If results caching is that critical,
I would suggest running 11g, which implements it.

--
__________________________________________________ _____________________
Dan Blum tool (AT) panix (DOT) com
"I wouldn't have believed it myself if I hadn't just made it up."


Reply With Quote
  #9  
Old   
Dan Blum
 
Posts: n/a

Default Re: Fetch table names from query - 05-21-2008 , 01:59 PM



DA Morgan <damorgan (AT) psoug (DOT) org> wrote:
Quote:
?lvaro G. Vicario wrote:
Is there any simple way to extract the table names of a given SELECT
query without actually running it?

I've implemented a very simple results cache in my PHP application but
I'd like to improve it. And one of the key points is finding out what
tables a query reads from so I can handle obsolete data. Writing a
reliable SQL parser in PHP looks like a hard task and obtaining a full
explain plan from the Oracle server looks like an overkill.

Any ideas?

Thank you in advance,

This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

For example I have organizations here in the US that are, by law,
required to keep data online for 7 years. It hopefully will never be
accessed. But on audit, if it isn't there, they are in a boatload of
trouble.

This is a really bad idea, for many reasons, you should drop
immediately. Leave managing the database to the database professionals.
It is not something someone writing PHP should involve themselves in.
I think he means he wants to identify obsolete data in his results cache,
so he can refresh it from the database, not delete data from the database.

However, I agree that this is not a wonderful idea, as it is essentially
recreating Oracle functionality. If results caching is that critical,
I would suggest running 11g, which implements it.

--
__________________________________________________ _____________________
Dan Blum tool (AT) panix (DOT) com
"I wouldn't have believed it myself if I hadn't just made it up."


Reply With Quote
  #10  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default Re: Fetch table names from query - 05-22-2008 , 03:11 AM



Dan Blum escribió:
Quote:
This is horrifying. Obsolete data is defined by an SLA with the customer
not by whether it is accessed.

I think he means he wants to identify obsolete data in his results cache,
so he can refresh it from the database, not delete data from the database.
Er... Yes, that's it. I can't even understand what Morgan means. A
results cache must not be such a bad idea if many major DBMS implement
it in recent versions, including Oracle itself.


Quote:
However, I agree that this is not a wonderful idea, as it is essentially
recreating Oracle functionality. If results caching is that critical,
I would suggest running 11g, which implements it.
However, the database server runs 10g. If I tell the customer that in
order to run an auxiliary web reports application they need to buy a
licence for 11g, upgrade their server, check that all existing apps
(functions, stored procedures, ERP, several custom Oracle Forms
utilities, online orders web site, backup system...) do not break... I'd
say they won't be amused.

So I assume the only way to obtaining table names is explain plan :-? I
guess I'll stick to my PHP-side solution by now.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.