

You must also specify an interval at which to repeat the statement, followed by a time unit. watch applies to all -execute or -e flags in use. Repeat the SQL statements specified with -execute or -e until a SQL error occurs or the process is terminated. This flag may be specified multiple times, once per option.Īfter starting the SQL shell, the \set and unset commands can be use to enable and disable client-side options as well. Set a client-side option before starting the SQL shell or executing SQL statements from the command line via -execute. Potentially unsafe SQL statements can also be allowed/disallowed for an entire session via the sql_safe_updates session variable. DROP COLUMN.ĭefault: true for interactive sessions false otherwise This flag corresponds to the display_format client-side option.ĭisallow potentially unsafe SQL statements, including DELETE without a WHERE clause, UPDATE without a WHERE clause, and ALTER TABLE. Possible values: tsv, csv, table, raw, records, sql, html.ĭefault: table for sessions that output on a terminal tsv otherwise How to display table rows printed to the standard output. The results of each statement are printed to the standard output (see -format for formatting options).įor a demonstration of this and other ways to execute SQL from the command line, see the example below. If an error occurs in any statement, the command exits with a non-zero status code and further statements are not executed. This flag can be set multiple times, and each instance can contain one or more statements separated by semi-colons. This can also be enabled within the interactive SQL shell via the \set echo shell command.Įxecute SQL statements directly from the command line, without opening a shell.

For a demonstration, see the example below. Reveal the SQL statements sent implicitly by the command-line utility.

Specifically, this flag removes details that users in an embedded environment have no control over (e.g., networking information). New in v21.1: Minimizes the SQL shell welcome text to be appropriate for embedding in playground-type environments. To execute SQL statements from the command line, use the -execute flag.Ī database name to use as current database in the newly created session.To start an interactive SQL shell, run cockroach sql with all appropriate connection flags or use just the -url flag, which includes connection details.

The sql command supports the following types of flags:
