Command-line options
When you type nzsql -h, the system displays the command-line options that you can use. For a list and descriptions of the all the command-line options, see Table 1.
- -A
- Unaligned table output mode
Normally output is well-formatted with white space added so that columns align. If you use the -A option, the nzsql command removes extra white space. Use this command when you want to compare results between two systems or when you want to transfer data.
- -c
- Run a single query and exit Use this option to run a single query. When you combine it with options -A and -t (print rows only), you can create useful scripts. For example, to find out the number of records in a table, enter:
#!/bin/bash EXPORT CNT=‘nzsql -A -t -c "SELECT COUNT (*) FROM $1"‘ echo "The number of records in table $1 is $CNT"
- -E
- Display queries that internal commands generate Use this option to see how the SQL is being generated. For example, \l displays the list of databases and when you add -E to the command line, the system shows you the actual SQL used to generate the list.
nzsql -E \l ********* QUERY ********* SELECT Database, Owner FROM _v_database ************************* List of databases database | owner --------------+------- database_one | admin database_two | admin system | admin (3 rows)
- -f
- Run queries from a file
- -F
- Set the field separator
The default delimiter between output columns is a pipe (|) symbol. When used with the -A option (unaligned output), you can specify a different delimiter string, such as a space, tab, comma, colon, or others. You can use the -R <string> to change the record separator. The default is newline.
- -H
- HTML table output mode
You can format the nzsql output to use HTML tags.
- -t
- Print rows only
Normally the nzsql command includes column headings and a summary row for all SQL queries. Use the -t option to eliminate the column headings and summary row. Use this option with the -A option to produce data in a transportable format.
- -x
- Expand table output
You can use this option to display the query results vertically instead of in the default table/2D grid.