Solved

Search Entire Database for String

Posted on 2007-12-04
1
3,168 Views
1 Endorsement
Last Modified: 2008-02-01
How do I go about searching an entire DB2 database for any instance of a string criteria?

i.e. Any field in any table with the string "%Testing%"
1
Comment
Question by:DJmistral
1 Comment
 
LVL 45

Accepted Solution

by:
Kdo earned 125 total points
ID: 20404910
Hi DJmistral,

You'll have to query each table.

One way to do that is to write SQL to generate SQL.  A relatively common thing for DBAs to do.

SELECT 'SELECT * FROM ' || rtrim(table_schema) || '.' || table_name || ' WHERE ' || Column_name || ' like ''%Testing%'';'
FROM sysibm.columns
WHERE table_schema = ''
  AND table_name = ''
  AND DATA_TYPE = 'CHARACTER VARYING';

Replace the '' with the appropriate schema and table names and that QUERY will generate SELECT statements for you.  Copy and past them into the client window and execute them.


Good Luck,
Kent
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question