shsql(1)(command)

shsql(1)

Synopsis
shsql options sqlcommand

Description
shsql(1) is a command line tool for submitting sql commands to the SHSQL database system. sqlcommand, as given on the command line, will be executed. If it is a SELECT command, the results will be written to standard output. The default output format is tabular tab-delimited, but there are a number of output options (see below). sqlcommand must be a single comand.

The shsql(1) command can only run one command-line query at a time. For a tool that can process SQL statements from a file, try quisp.

Environment
Described here

Examples

shsql -h "select * from institutions order by name"

shsql -html -nullrep "&nbsp;" "select * from institutions order by name"

shsql "update institutions set city = 'Madison, WI' where id = 50"

shsql "create table wantlist ( id, description, estprice type=num )"

General options

-id identity

    Associate the given identity with the SQL command (equivalent to issuing an IDENTITY command).

-nolog

    Suppress the generation of transaction logs when the database is updated.

-rowcount

    Execute the command and set the exit code to the number of rows retrieved or affected, but do not write any results to standard output.

Output format options

-h

    First line of output will be a row of field names.

-n

    "Nicely" formatted output, one row per record, for human consumption. All fields, except the leftmost, are centered, which may not be ideal. Implies -h. Should not be used in combination with -delim, -xml, -html, or -tagvalue. May be used with -nullrep, but chosen null representation must be something other than whitespace.

-nat

    "Native" output, ie. data table storage format, with fields delimited by a space, and nulls represented using the null symbol equals sign (=) by default. Equivalent to -delim space -nullrep =.

-l maxlen

    Set the maximum length for all output fields. Any output field longer than maxlen characters will be truncated for display purposes.

-xlen lenlist

    Explicit setting of individual output field lengths. lenlist is a comma-delimited list of lengths (integers) with no embedded spaces, dictating the maximum length for each output field. List members that are 0 or missing will cause the corresponding fields to not be truncated.
    Example: -xlen "0,0,20,0,40"
    This would truncate output field 3 at 20 characters, and output field 5 at 40 characters.

-nullrep sym

    By default, NULL fields are shown as null. This option may be used to display NULL fields using the given sym.
    Example: -nullrep ""

-delim char

    Output fields will be delimited by char. Allowable values are space, tab, or any character. Default is tab. If delim is space, space characters embedded within fields will be displayed as underscores.

-omitfinaldelim

    If specified, the final field in the result rows will not be followed by a field delimiter or a newline. This may be useful for retrieving fields into shell scripts.

-und fieldlist

    Display embedded underscores as is in certain fields. Normally embedded underscores are assumed to represent spaces, and displayed as such. fieldlist is a comma-delimited list of field numbers with no embedded spaces.
    Example: -und 3,7
    This would display output fields 3 and 7 with underscores intact.

-tagvalue

    Format the output as simple tag: value lines. Most of the formatting options above have no effect when using -tagvalue.

-html

    Format the output as HTML table rows. NULLs will be presented as cells containing a single space (&nbsp;). Most of the formatting options above have no effect when using -tagvalue.

-xml

    Format the output as an XML list. Most of the formatting options above have no effect when using -tagvalue.

-omitnull

    Don't output entries for fields which are null. Useful only with -xml and -tagvalue.

Development & debugging options

-ttprefix string

    Use string for naming temp table files, instead of a unique process tag. Allows temp tables to be shared between different shsql processes.

-debug

    Display debugging output to standard error.

-debug2

    Display additional debugging output related to index lookups.

-noindex

    Suppress indexed access for debugging purposes.

-echo

    Echo the given sql command to standard output.

-terse

    Produce shorter error messages, without a copy of the given sql command.

-footprint

    This displays memory footprint at beginning and end of run, in kB. Figures are written to standard error. The command ps -o vsz -o rss is invoked internally to accomplish this.

-ver

    Display the shsql version number.