Netezza SET CATALOG command: Connect to Different Database from same Session

  • Post author:
  • Post last modified:February 27, 2018
  • Post category:Netezza
  • Reading time:3 mins read

If you are a business analyst or data architect then you have to work on the different database to identify the relevant data to come up with business decisions on a particular design. You can connect to multiple databases from the current Netezza sessions using Netezza SET CATALOG command

Netezza SET CATALOG command

Use the SET CATALOG command to connect to a different Netezza database in the same session. This command is the session specific i.e. as soon as the execution ends in current session; Netezza reverts back to the original database.

Read:

Netezza SET CATALOG command Syntax

Below is the syntax of the Netezza SET CATALOG command:

SET CATALOG <database_name>;

The only requirement here is, you should run the above command with the database name from which you want to extract the data.

Netezza SET CATALOG command Examples

You can add the Netezza SET CATALOG command in the command window or to the script that you want to execute as a part of your execution. Below is the example of windows SQL tool (Aginity Workbench)

SET CATALOG TRAINING;
SELECT * FROM NAMES;
ID Names Course
1 Anil CS
2 Rahul IT
3 Smith IT
4 Ruby FIN
5 Ana CS

Below shows the examples of using Netezza SET CATALOG from linux:

TRAINING.ADMIN(ADMIN)=> \c test 
You are now connected to database test. 
TEST.ADMIN(ADMIN)=> SET CATALOG training ;
SET CATALOG 
TRAINING.ADMIN(ADMIN)=> select * from STUDENTS; 
 CLASS | SECTION | PASS_FAIL | COUNT 
--------+---------+-----------+------- 
 CLASS1 | A | FAIL | 123 
 CLASS1 | A | PASS | 321 
 CLASS2 | B | FAIL | 333 
 CLASS2 | B | PASS | 543 
(4 rows) 
TRAINING.ADMIN(ADMIN)=>