By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,019 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,019 IT Pros & Developers. It's quick & easy.

How to list an instances databases

P: n/a
Is there a command that will list all of the databases for a particular
instance on the local machine, whether they are activated or not?

If there is no such command, is there at least a way to list only the local
databases in the db directory, and tie them back to the instance they
belong to?
--
Chuck
Remove "_nospam" to reply by email
Nov 12 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a

"Chuck" <ch***********@softhome.net> wrote in message
news:Xn**********************************@130.133. 1.4...
Is there a command that will list all of the databases for a particular
instance on the local machine, whether they are activated or not?

If there is no such command, is there at least a way to list only the local databases in the db directory, and tie them back to the instance they
belong to?


You didn't say which DB2 platform and version you are using so my remarks
pertain to V7.2 (PE) on Windows.

It's not the neatest solution in the world but if you use the Control
Center, you can easily list which databases belong to each instance. To
determine which ones are active, just execute:
db2 list active databases

The output lists the database names of each database that is active. That
should enable you to determine which ones are active and which are not.

Like I said, it's a bit of manual work, especially if you have a lot of
databases, but they say hard work builds character ;-)

If this is something you have to do frequently, you may be able to write
your own utility for it via the DB2 API. Or not; I haven't looked to see if
the necessary functions are all present in the API.

Rhino
Nov 12 '05 #2

P: n/a
Ian
Chuck wrote:
Is there a command that will list all of the databases for a particular
instance on the local machine, whether they are activated or not?


list database directory
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 12 '05 #3

P: n/a
Ian <ia*****@mobileaudio.com> wrote in news:40b6d34d$1_1
@corp.newsgroups.com:
list database directory


That lists all databases cataloged in the DB directory. Even one's on other
machines. What I'm looking for is a list of the databases that belong to
one instance on the local machine.

Platform AIX 5.2, DB2 8.1.

--
Chuck
Remove "_nospam" to reply by email
Nov 12 '05 #4

P: n/a
In article <Xn**********************************@130.133.1.4> , Chuck
(ch***********@softhome.net) says...
Ian <ia*****@mobileaudio.com> wrote in news:40b6d34d$1_1
@corp.newsgroups.com:
list database directory


That lists all databases cataloged in the DB directory. Even one's on other
machines. What I'm looking for is a list of the databases that belong to
one instance on the local machine.

Platform AIX 5.2, DB2 8.1.


db2 list db directory on <local-path>
Nov 12 '05 #5

P: n/a
Ian
Chuck wrote:
Ian <ia*****@mobileaudio.com> wrote in news:40b6d34d$1_1
@corp.newsgroups.com:

list database directory

That lists all databases cataloged in the DB directory. Even one's on other
machines. What I'm looking for is a list of the databases that belong to
one instance on the local machine.

Platform AIX 5.2, DB2 8.1.


OK, I guess I'm not following. You can use grep to eliminate the remote
databases from the 'list database directory' output:

db2 list db directory | grep -vp Remote

If you're looking for other databases that do not exist in the database
directory... you may have a bigger problem. :-)

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 12 '05 #6

P: n/a
list db directory on /db2dir (db directory path) : will show local database
list active databases : will show databases that are active
Chuck <ch***********@softhome.net> wrote in message news:<Xn**********************************@130.133 .1.4>...
Ian <ia*****@mobileaudio.com> wrote in news:40b6d34d$1_1
@corp.newsgroups.com:
list database directory


That lists all databases cataloged in the DB directory. Even one's on other
machines. What I'm looking for is a list of the databases that belong to
one instance on the local machine.

Platform AIX 5.2, DB2 8.1.

Nov 12 '05 #7

P: n/a
ud****@yahoo.com (Mike Lebermann) wrote in
news:f4*************************@posting.google.co m:
list db directory on /db2dir (db directory path) : will show local
database list active databases : will show databases that are
active Chuck <ch***********@softhome.net> wrote in message
news:<Xn**********************************@130.133 .1.4>...
Ian <ia*****@mobileaudio.com> wrote in news:40b6d34d$1_1
@corp.newsgroups.com:
> list database directory


That lists all databases cataloged in the DB directory. Even one's on
other machines. What I'm looking for is a list of the databases that
belong to one instance on the local machine.

Platform AIX 5.2, DB2 8.1.


Only if all the databases are on the same path. I can have two databases
in the same instance that are not on the same path.
--
Chuck
Remove "_nospam" to reply by email
Nov 12 '05 #8

P: n/a
Gert van der Kooij <ge**@invalid.nl> wrote in
news:MP************************@news.xs4all.nl:
In article <Xn**********************************@130.133.1.4> , Chuck
(ch***********@softhome.net) says...
Ian <ia*****@mobileaudio.com> wrote in news:40b6d34d$1_1
@corp.newsgroups.com:
> list database directory


That lists all databases cataloged in the DB directory. Even one's on
other machines. What I'm looking for is a list of the databases that
belong to one instance on the local machine.

Platform AIX 5.2, DB2 8.1.


db2 list db directory on <local-path>


I can still have two dbs on different paths but are part of the same
instance.
--
Chuck
Remove "_nospam" to reply by email
Nov 12 '05 #9

P: n/a
Ian <ia*****@mobileaudio.com> wrote in
news:40**********@corp.newsgroups.com:
Chuck wrote:
Ian <ia*****@mobileaudio.com> wrote in news:40b6d34d$1_1
@corp.newsgroups.com:

list database directory

That lists all databases cataloged in the DB directory. Even one's on
other machines. What I'm looking for is a list of the databases that
belong to one instance on the local machine.

Platform AIX 5.2, DB2 8.1.


OK, I guess I'm not following. You can use grep to eliminate the
remote databases from the 'list database directory' output:

db2 list db directory | grep -vp Remote


Ah, but I could have multiple instances on the local machine. I only want
the dbs associated with one local instance.

Besides, the output from the list db directory command is split over
several lines for each db. For grep to work you'd need to first find some
wat to combine all the lines for a db into a single line.

--
Chuck
Remove "_nospam" to reply by email
Nov 12 '05 #10

P: n/a
Ian
Chuck wrote:
Ian <ia*****@mobileaudio.com> wrote in
news:40**********@corp.newsgroups.com:

Chuck wrote:
Ian <ia*****@mobileaudio.com> wrote in news:40b6d34d$1_1
@corp.newsgroups.com:

list database directory
That lists all databases cataloged in the DB directory. Even one's on
other machines. What I'm looking for is a list of the databases that
belong to one instance on the local machine.

Platform AIX 5.2, DB2 8.1.

OK, I guess I'm not following. You can use grep to eliminate the
remote databases from the 'list database directory' output:

db2 list db directory | grep -vp Remote

Ah, but I could have multiple instances on the local machine. I only want
the dbs associated with one local instance.


'list db directory' only lists databases cataloged in the current instance.
Besides, the output from the list db directory command is split over
several lines for each db. For grep to work you'd need to first find some
wat to combine all the lines for a db into a single line.


On AIX, this is precisely what the -p option does: It prints the
"paragraph" that has a line containing the info you are looking for.

So, the command 'db2 list db directory | grep -vp Remote' will print out
the database directory information for local databases in the current
instance. If you want just the database names,

db2 list db directory | grep -vp Remote | \
grep 'Database name' | awk '{print $4}'


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 12 '05 #11

P: n/a
Ian <ia*****@mobileaudio.com> wrote in
news:40**********@corp.newsgroups.com:

'list db directory' only lists databases cataloged in the current
instance.
Didn't realize that. (I'm still a newbie).
Besides, the output from the list db directory command is split over
several lines for each db. For grep to work you'd need to first find
some wat to combine all the lines for a db into a single line.


On AIX, this is precisely what the -p option does: It prints the
"paragraph" that has a line containing the info you are looking for.

So, the command 'db2 list db directory | grep -vp Remote' will print
out the database directory information for local databases in the
current instance. If you want just the database names,

db2 list db directory | grep -vp Remote | \
grep 'Database name' | awk '{print $4}'


It still missed one of my local DBs for some reason, but changing the first
grep to 'grep "Local database directory" ' did the trick. Thanks for
helping me out and setting me straight on the exact behaviour of the list
db directory command.
--
Chuck
Remove "_nospam" to reply by email
Nov 12 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.