IBM PureData System for Analytics, Version 7.1

The nzsql command

The nzsql command invokes a SQL command interpreter on the IBM® Netezza® host or on a UNIX client system. You can use this SQL command interpreter to create database objects, run queries, and manage the database.

Note: The nzsql command is not available on Windows client systems.
To run the nzsql command, enter:
nzsql [options] [security options] [dbname [user] [password]]
The following table describes the nzsql command parameters. For more information about the command parameters and how to use the command, see the IBM Netezza Database User’s Guide.
Table 1. nzsql command parameters
Parameters Description
-a Echo all input from a script.
-A Use unaligned table output mode. This is equivalent to specifying -P format=unaligned.
-c <query> Run only a single query (or slash command) and exit.

-d <dbname>
or
-D <dbname>

Specify the name of the database to which to connect. If you do not specify this parameter, the nzsql command uses the value specified for the NZ_DATABASE environment variable (if it is specified) or prompts you for a password (if it is not).
-schema <schemaname> Specify the name of the schema to which to connect. This option is used for Netezza Release 7.0.3 and later systems that are configured to use multiple schemas. If the system does not support multiple schemas, this parameter is ignored. If you do not specify this parameter, the nzsql command uses the value specified for the NZ_SCHEMA environment variable (if it is specified) or a schema that matches the database account name (if it is not and if enable_user_schema is set to TRUE), or the default schema for the database (otherwise).
-e Echo queries that are sent to the server.
-E Display queries generated by internal commands.
-f <file name> Run queries from a file, then exit.
-F <string> Set the field separator. The default: is a vertical bar (|). This is equivalent to specifying -P fieldsep=<string>.
-h Display help for the nzsql command.
-H Set the table output mode to HTML. This is equivalent to specifying -P format=html.
-host <host> Specify the hostname of the database server.
-l List available databases, then exit.
-n Disable readline mode. This is required when input uses a double-byte character set such as Japanese, Chinese, or Korean
-o <file name> Send query output to the specified file or, if a vertical bar (|) is specified instead of a file name, to a pipe.
-P opt[=val] Set the printing option represented by opt to the value represented by val.
-port <port> Specify the database server port.
-pw <password> Specify the password of the database user. If you do not specify this parameter, the nzsql command uses the value specified for the NZ_PASSWORD environment variable (if it is specified) or prompts you to enter a password (if it is not).
-q Run quietly, that is, without issuing messages. Only the query output is returned.
-r Suppress the row count that otherwise is displayed at the end of the query output.
-R <string> Set the record separator. The default is the newline character. This is equivalent to specifying -P recordsep=<string>.
-s Use single-step mode, which requires that each query be confirmed.
-S Use single-line mode, which causes a newline character to terminate a query.
-t Print rows only This is equivalent to specifying -P tuples_only.
-time Print the time that is taken by queries.
-T <text> Set the HTML table tag options such as width and border. This is equivalent to specifying -P tableattr=<text>.

-u <username>
or
-U <username>

Specifies the database user name. If you do not specify this parameter, the nzsql command uses the value specified for the NZ_USER environment variable (if it is specified) or prompts you to enter a user name (if it is not).
-V Display version information and exit.
-v <name>=<value> Set the specified session variable to the specified value. Specify this parameter once for each variable to be set, for example:
nzsql -v HISTSIZE=600 -v USER=user1 -v PASSWORD=password
-x Expand table output. This is equivalent to specifying -P expanded.
-X Do not read the startup file (~/.nzsqlrc).
-securityLevel <level> Specify the security level (secured or unsecured) for the connection to the Netezza system:
preferredUnSecured
You prefer an unsecured connection, but you will accept a secured connection if the system is configured to use only secured connections. This is the default.
preferredSecured
You prefer a secured connection, but you will accept an unsecured connection if the system is configured to use only unsecured connections.
onlyUnSecured
You require an unsecured connection. If the system is configured to use only secured connections, the connection attempt is rejected.
onlySecured
You require a secured connection. If the system is configured to use only unsecured connections or has a release level that is earlier than 4.5, the connection attempt is rejected.
-caCertFile <path> Specify the path to the root CA certificate file on the client system. This option is used by Netezza clients that use peer authentication to verify the Netezza host system. The default value is NULL, which skips the peer authentication process.
Within the nzsql command interpreter, you use the following slash commands:
\h
List all SQL commands.
\h <command>
Display help about the specified SQL command.
\?
List and display help about all slash commands.
\g
Run a query. This has the same effect as terminating the query with a semicolon.
\q
Quit


Feedback | Copyright IBM Corporation 2014 | Last updated: 2014-02-28