If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL - Find rows in all tables of a Schema

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-23-09, 13:35
rockycj rockycj is offline
Registered User
 
Join Date: Feb 2007
Posts: 73
SQL - Find rows in all tables of a Schema

Is there a way to retrieve ALL rows in all tables of a schema?

For example, if I'm looking for all rows with a fieldname of "app_id" within a schema name with about 40 tables:

select *
from schemaname.alltables
where app_id = ?

I want to retrieve from all 40 tables instead of manually selecting for each table within the schema.

Please send me any examples and/or explain if this is possible.
Thank you.

CC
Reply With Quote
  #2 (permalink)  
Old 09-23-09, 13:45
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
so, you have 40 tables in your schema. Some of them have a column called APP_ID. and you only want to select from those tbales that have this column?

If yes? query catalog for the list of tables that has this column. use that list to build your select statement. There are many way to accomplish this. I would probably script it, let it rip and go to lunch
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #3 (permalink)  
Old 09-23-09, 13:48
rockycj rockycj is offline
Registered User
 
Join Date: Feb 2007
Posts: 73
All tables within this schema have the field app_id

All of the tables within this schema have the field called "app_id". So instead of doing a select on each of the 40 tables, I would like to do it in 1 select statement, if possible.

Thanks.

CC
Reply With Quote
  #4 (permalink)  
Old 09-23-09, 13:52
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Sure. Export all of your data to ONE .txt file. Then you can do what you are asking.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On