Netezza ODBC Connection - Usage Database Equivalent

After connecting to a Netezza system, is there a way to switch the database? For example, in MSSQL, you can send the use database_name command to switch to database_name.

Is there anything in Netezza how to "use" on mssql?

http://technet.microsoft.com/en-us/library/ms188366.aspx

My reason for the request is metadata requests; I can only access _v_table from the "current connected database".

+6
source share
4 answers

Prior to Version 7.0 there was no equivalent to USE . You should have logged into certain databases on the server, but you can still access any object using. database.schema.objectname

Post Version 7.0 equivalent of Set Catalog

 SET CATALOG <database_name> 

Regarding your specific request. Please consider using _V_TABLE_XDB instead of _V_TABLE . This system table should provide you with a list of all tables, not just those in the database to which you are connected.

+11
source

If you use NPS v7.0 +, the SET CATALOG command will dynamically connect to another database (without the need to disconnect and reconnect). The beauty of this command is that it can be sent from the ODBC / JDBC client, as well as in the nzsql script.

+5
source

In Netezza you can to another database with the following command -

 nzsql -u <username> -pw <password> -db <databasename> -host <netezza server IP> 

Hope this helps you.

+3
source

As we know, when executing any request in netezza, we need to specify the database name in the connection URL, which we must make dynamic in accordance with the required database with which we must perform the operation, so in case of simple Java code, we can use case below. 1) and in the case of spring loading, we can use case 2) below.

Case 1) before executing any request in netezza, we can execute the statement as

SET CATALOG # database name #;

therefore, it will automatically switch to the database specified in the set command.

Case 2) We can switch the database in netezza with switching the database at runtime

  1. Use the Apache base data source ( BasicDataSource ) instead of DriverManagerDataSource when creating the component for the data source

  2. Run - jdbcTemplate.execute ("SET CATALOG #database name #") before executing any query.

0
source

All Articles