Chapter 10 – Using nzsql

“Only dead fish swim with the stream.”

Anonymous

 

Using nzsql

image

When you invoke the nzsql command, you must supply a user name, password, and the name of the database to which you are connecting. You can enter this information on the nzsql command line, or you can specify the information in environment variables and export those variables before you begin your nzsql session. Above, we have connected without exporting.

 

The nzsql Command Prompt

image

When you invoke the nzsql command, you must supply a user name, password, and the name of the database to which you are connecting. You can enter this information on the nzsql command line, or you can specify the information in environment variables and export those variables before you begin your nzsql session. Above, we have connected without exporting.

 

Exporting Variable and then Using nzsql

image

When you invoke the nzsql command, you must supply a user name, password, and the name of the database to which you are connecting. You can enter this information on the nzsql command line, or you can specify the information in environment variables and export those variables before you begin your nzsql session. Above, we have connected to nzsql directly after exporting our NZ_USER, NZ_PASSWORD and NZ_DATABASE variables.

 

Connecting to another database through nzsql

image

This slide is designed to teach you about the nzsql prompt.

 

Displaying SQL User Session Variables

image

You can display the current user-defined session variables using the set command with no arguments as seen above.

 

Inserts, Updates and Deletes Show the Number of Rows

image

The system feedback for inserts, updates, and deletes shows you the number of rows affected. The feedback for inserts includes an extra zero before the actual number (due to past designs). Sample commands (shown in blue) and the command feedback are listed above.

 

Running a SQL Query from the nzsql Command Line

image

Above is a simple way to run a single query using nzsql directly from the command line.

 

Nzsql Options That Might Come In Handy

image

Above are some great examples that might come in handy.

 

Nzsql Internal Slash Options

image

When you use the nzsql command in interactive mode, there are many options that you can use. These options, known as internal slash options, are called with a backslash ().

 

Nzsql For External Tables

image

External Tables are how Netezza imports and exports data to and from a Netezza system.

 

Why Would Anyone Use nzsql When They Can Use Nexus?

image

Why anyone would still be using nzsql when they have the Nexus is a mystery. Utilize nzsql if you are in desperate need, but the Nexus makes Netezza so incredibly easy to query and manage that this is the recommended tool for everything Netezza. By the way, the Nexus works on every platform including Hadoop!

 

The Nexus Super Join Builder Shows Tables Visually

image

Nexus works on every system, but the most impressive thing is that Nexus shows tables and views visually. It also shows what tables and views can be joined together. Above, you can see that these five tables join together. All the user has to do is click on the column they want on their report, and Nexus builds the SQL for them. Just right click on any table in any system, and click Super Join Builder. Then, watch in amazement as Nexus handles everything for you with each click of the mouse. Turn the page and see the SQL that Nexus built.

 

The Nexus Super Join Builder Builds the SQL Automatically

image

The Nexus automatically built the SQL for our five table join in seconds. Each time a user right clicks on a table and chooses the Super Join Builder, the table or view is shown visually (in the objects tab). As the user clicks on the right corner of the table, they are shown what joins to the table. As they choose the tables they want, they can then choose the columns. As each column is selected, the Nexus builds the SQL in the SQL tab (red arrow above). This is how queries should be built! In seconds! If you love Nexus on Netezza, just wait till you try it on Hadoop!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.233.205