Session management
Each client user who connects to the Netezza system opens a session. Users can view information about their sessions, and manage them to do such tasks as alter or drop their sessions. The admin account or any permitted user can also show, drop, and manage sessions. For a description of the SQL commands to manage sessions (ALTER SESSION, DROP SESSION, and SHOW SESSION), see Netezza Performance Server SQL command reference.
Within a session, you can use the SET CATALOG command to change to a different database. You can use the SET SCHEMA command to change to a different schema in the current database. For example:
SYSTEM.ADMIN(ADMIN)=> SET CATALOG MYDB;
SET CATALOG
MYDB.ADMIN(ADMIN)=> SET SCHEMA BLUE;
SET SCHEMA
MYDB.BLUE(ADMIN)=>
Within the nzsql command environment, you can also use the \c option to connect to a new database. Unlike the SET CATALOG command, the \c option closes the current session and starts a new session to the database. The option syntax is as follows:
\c[onnect] [dbname [user] [password]]
For example, the following command connects to the database named sales as the user mlee with the password blue.
SYSTEM.ADMIN(ADMIN)=> \c sales mlee blue
You are now connected to database sales as user mlee.
SALES.SCHEMA(MLEE)=>
After you open the session to the new database, you can use the SET SCHEMA command to change to a different schema in that database.