Selecting Database Connection, Catalog and Schema
You use the Database Connection and Database (or Catalog) lists above the editor to specify which connection and database to use when executing the SQL in the SQL Commander. The list of connections shows all connections as they are ordered in the Databases tab tree, except that all currently active connections are listed first.
The screenshot shows the Sakila database being selected. When hovering over the name, its full path including any folders is listed in a tooltip.
If you check the Sticky box above the Database Connection, the current connection selection will not change automatically when passing SQL statements from other parts of DbVisualizer, for instance, when opening a Bookmark. Consider a Bookmark defined for database connection Prod
. If the Sticky checkbox is not checked (i.e., disabled), the database connection is automatically changed to Prod
when you open the Bookmark in the SQL Editor. However, if the Sticky checkbox is checked (i.e. enabled), the current database connection setting is unchanged. You can specify if you want to have Sticky enabled by default in the Tool Properties dialog, in the SQL Commander category under the General tab.
The Database list (or Catalog) defines which catalog in the connection is the target for the execution. Since not all databases use catalogs, this list may be disabled.
For most databases, the schema selected in the Schema list is used only to limit the tables the Auto-Completion feature shows in the completion pop-up; it does not define a default schema for tables referenced in the SQL since most databases do not allow the default schema to be changed during a session.
For databases that allow the default schema to be changed*, the selected schema is also used as the default schema, i.e., the schema used for unqualified table names in the SQL. If the Database Type is set to Generic for a connection, DbVisualizer tries to set the default schema (if Use Schema is chosen) but it depends on the JDBC driver if this works or not.
If you don't want the selected schema to be used as the default schema for a database, you can disable this behavior in the Properties tab for the connection, in the SQL Commander category.
*) Examples of databases that support setting a default schema include Db2 LUW, Db2 z/OS, Db2 iSeries, Greenplum, H2, JavaDB/Derby, Oracle, NuoDB, PostgreSQL, Vertica, and Yellowbrick.
Configuring the Initial Values
When a new Database Connection is selected, the initial values for the Database and Schema lists are by default based on the default values for the connection. You can change this behavior in the Properties tab for the connection, in the SQL Commander category. The initial value for each list that is applicable for the database type can be set to one of The Connection Default, None or The Most Recently Used.