Question: What do
I do to locate a table that exists in one of many databases?
I know how to find a table in one database using dba_tables,
but I need to check all of the databases for the table name.
How do I quickly check all databases for a table?
Answer: To connect to all
databases on all Oracle servers, the following script will
connect to each database and check for the table name:
This will
visit every database in your
enterprise. In the following example, we perform a double
loop, looping from server to server. For each server, we
loop from database to database. Here is the actual UNIX code
that perform the loops.
# Loop through each host name
. . .
for host in `cat ~oracle/.rhosts|cut -d"." -f1|awk
'{print $1}'|sort -u`
do
echo " "
echo "************************"
echo "$host"
echo "************************"
# Loop through
each database name on the host /etc/oratab . . .
for db in `rsh $host "cat /etc/oratab|egrep ':N|:Y'|grep -v
\*|\
cut -f1 -':'"`
do
# Get the ORACLE_HOME for each database
home=`rsh $host "cat /etc/oratab|egrep ':N|:Y'|grep -v \*|\
grep {db}|cut -f2 -d':'"`
echo " "
echo "database is $db"
sqlplus system/manager@$db <<!
select owner from dba_tables where table_name = 'FRED';
exit;
!
done
done
This will search on all Oracle servers, and all instances
on each server for a table.
WARNING! This trick is only for
secure shops without any outside access (internet
connectivity). There is a security exposure with rsh
because a hack into one server will expose all servers that
they can rsh onto. Hence, this tip is only for secured
server farms where rsh can be safely implemented.
|
|
|
Oracle Training from Don Burleson
The best on site
"Oracle
training classes" are just a phone call away! You can get personalized Oracle training by Donald Burleson, right at your shop!

|
|
|

|
|
Burleson is the American Team

Note:
This Oracle
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
Oracle forum.
Verify
experience!
Anyone
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
publish
their Oracle
qualifications.
Errata?
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
feedback. Just
e-mail:
and include the URL for the page.
Copyright © 1996 - 2020
All rights reserved by
Burleson
Oracle ®
is the registered trademark of Oracle Corporation.
|
|