In the following examples, the IBM® Netezza® system has two databases, PROD and DEV, and each database has a table that is named EMP. While connected to the DEV database, you can retrieve all rows from the table EMP using the following command.
DEV.DBUSER(DBUSER)=> SELECT * FROM emp;
While connected to DEV, if you want to select rows from the EMP table in PROD, you can use the database.schema.object name format to identify the table, for example:
DEV.DBUSER(DBUSER)=>SELECT * FROM prod.dbuser.emp;
You cannot use a cross-database INSERT, UPDATE, or DELETE statements to change a table in a different, remote, database. If you attempt a cross-database write operation, the system displays an error message. For example:
DEV.DBUSER(DBUSER)=>INSERT INTO prod..emp SELECT * FROM newusers;
Cross Database Access not supported for this type of command.
For this type of query, you can change the query to a cross-database SELECT statement by using the SET CATALOG command to change to the PROD database. For example:
DEV.DBUSER(DBUSER)=>SET CATALOG PROD;
SET CATALOG
PROD.DBUSER(DBUSER)=>INSERT INTO emp SELECT * FROM dev.dbuser.newusers;
You cannot use CREATE, ALTER, or DROP commands to change objects in a database that is not your current database. If you attempt to do so, the system displays an error message. For example:
DEV.DBUSER(DBUSER)=>CREATE SEQUENCE prod.dbuser.seq1;
Cross Database Access not supported for this type of command.