elbarna
elbarna

Reputation: 727

db2: how to connect to favorite/prefer db?

On Oracle is easy

sqlplus myuser/mypass@remotehost/nameofdborcontainer

On db2 I do this

db2
connect to mydb

How to connect automatically to mydb?

Upvotes: 0

Views: 91

Answers (1)

mustaccio
mustaccio

Reputation: 18945

You cannot always draw parallels between Oracle and Db2, because these DBMSes have very different architecture.

Historically an Oracle instance was only able to support one database, so connecting to an instance and the database were essentially the same thing. Recently this has changed with the introduction of pluggable databases, but the SQL*Plus behaviour remained backwards-compatible.

Db2 for LUW has always supported multiple databases per instances, so a connect command has been necessary to choose one of them.

You can avoid having to explicitly connect to a database by setting the registry variable DB2DBDFT that specifies the default database name for implicit connections. If it is set, any SQL statement will cause the client to connect to the specified database automatically.

Upvotes: 1

Related Questions