Search code examples
db2schemaaliasdb2-luw

IBM DB2, create an alias to database with schemas and tables


I have a database (list db directory):

Database 4 entry:
Database alias                       = ABC
Database name                        = ABC
Local database directory             = /data
Database release level               = f.00
Comment                              =
Directory entry type                 = Indirect
Catalog database partition number    = 0
Alternate server hostname            =
Alternate server port number         =

I need to have an alias for that database because my application tries to connect to database DEF.

I can create an alias using

catalog db ABC as DEF

then the (list db directory) shows:

Database 4 entry:
Database alias                       = ABC
Database name                        = ABC
Local database directory             = /data
Database release level               = f.00
Comment                              =
Directory entry type                 = Indirect
Catalog database partition number    = 0
Alternate server hostname            =
Alternate server port number         =code here

Database 5 entry:
Database alias                       = DEF
Database name                        = ABC
Local database directory             = /data
Database release level               = f.00
Comment                              =
Directory entry type                 = Indirect
Catalog database partition number    = 0
Alternate server hostname            =
Alternate server port number         =

But after I connect to aliased db using:

db2 connect DEF

I can't access any schemas and tables from original database. Of course when I connect using ABC database name everything is visible and on place.

Am I misunderstanding aliases in DB2? Or maybe there is some option like "create an alias with data" or something like that?


Solution

  • @mao - You are right! I've been connected using external software to one node, and using shell db2 to other node. That was the reason that i wasn't able to see databases.