GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • V15 Documentation
  • Privacy Statement
  • License Agreement
  • Contact Us

This view

  • Original page
  • New address

GeezerVison is showing docs.voltdb.com — sqlcmd

  • Volt Active Data
  • Developer Hub
  • Books
    • VoltDB Tutorial
    • Using VoltDB
    • VoltDB Guide to Performance and Customization
    • VoltDB Administrator's Guide
    • Volt Kubernetes Administrator's Guide
    • VoltDB Quick Reference
  • Current docs ▶
  • VoltDB V15
    • VoltDB V16
    • VoltDB V15.3 LTS
    • VoltDB V14.3 LTS
    • VoltDB V13.3 LTS
    • VoltDB V12.3 LTS
    • VoltDB V11.4
    • VoltDB V10.2
    • VoltDB V9.3
sqlcmd

Using VoltDB

  • About This Book
  • 1. Overview▶
    • 1.1. What is VoltDB?
    • 1.2. Who Should Use VoltDB
    • 1.3. How VoltDB Works
      • 1.3.1. Partitioning
      • 1.3.2. Serialized (Single-Threaded) Processing
      • 1.3.3. Partitioned vs. Replicated Tables
      • 1.3.4. Ease of Scaling to Meet Application Needs
    • 1.4. Working with VoltDB Effectively
  • 2. Installing VoltDB▶
    • 2.1. Operating System and Software Requirements
    • 2.2. Installing VoltDB
      • 2.2.1. Upgrading From Older Versions
    • 2.3. Setting Up Your Environment
    • 2.4. What is Included in the VoltDB Distribution
  • 3. Starting the Database▶
    • 3.1. Initializing and Starting a VoltDB Database
    • 3.2. Initializing and Starting a VoltDB Database on a Cluster
    • 3.3. Stopping a VoltDB Database
    • 3.4. Saving the Data
    • 3.5. Restarting a VoltDB Database
    • 3.6. Updating Nodes on the Cluster
    • 3.7. Defining the Cluster Configuration
      • 3.7.1. Determining How Many Sites per Host
      • 3.7.2. Configuring Paths for Runtime Features
      • 3.7.3. Verifying your Hardware Configuration
  • 4. Designing the Database Schema▶
    • 4.1. How to Enter DDL Statements
    • 4.2. Creating Tables and Primary Keys
    • 4.3. Analyzing Data Volume and Workload
    • 4.4. Partitioning Database Tables
      • 4.4.1. Choosing a Column on which to Partition Table Rows
      • 4.4.2. Specifying Partitioned Tables
      • 4.4.3. Design Rules for Partitioning Tables
    • 4.5. Replicating Database Tables
      • 4.5.1. Choosing Replicated Tables
      • 4.5.2. Specifying Replicated Tables
    • 4.6. Modifying the Schema
      • 4.6.1. Effects of Schema Changes on Data and Clients
      • 4.6.2. Viewing the Schema
      • 4.6.3. Modifying Tables
      • 4.6.4. Adding and Dropping Indexes
      • 4.6.5. Modifying Partitioning for Tables and Stored Procedures
  • 5. Designing Stored Procedures to Access the Database▶
    • 5.1. How Stored Procedures Work
      • 5.1.1. VoltDB Stored Procedures are Transactional
      • 5.1.2. VoltDB Stored Procedures are Deterministic
    • 5.2. The Anatomy of a VoltDB Stored Procedure
      • 5.2.1. The Structure of the Stored Procedure
      • 5.2.2. Passing Arguments to a Stored Procedure
      • 5.2.3. Creating and Executing SQL Queries in Stored Procedures
      • 5.2.4. Interpreting the Results of SQL Queries
      • 5.2.5. Returning Results from a Stored Procedure
      • 5.2.6. Rolling Back a Transaction
    • 5.3. Installing Stored Procedures into the Database
      • 5.3.1. Compiling, Packaging, and Loading Stored Procedures
      • 5.3.2. Declaring Stored Procedures in the Schema
      • 5.3.3. Partitioning Stored Procedures in the Schema
  • 6. Designing VoltDB Client Applications▶
    • 6.1. Connecting to the VoltDB Database
      • 6.1.1. How Connections To The Cluster Work
      • 6.1.2. Specifying Multiple Servers
    • 6.2. Invoking Stored Procedures
    • 6.3. Invoking Stored Procedures Asynchronously
    • 6.4. Defining Options on a Per-Call Basis
    • 6.5. Closing the Connection
    • 6.6. Handling Errors
      • 6.6.1. Interpreting Execution Errors
      • 6.6.2. Handling Timeouts
      • 6.6.3. Writing Handlers to Interpret Other Errors
    • 6.7. Compiling and Running Client Applications
      • 6.7.1. Starting the Client Application
      • 6.7.2. Running Clients from Outside the Cluster
  • 7. Simplifying Application Development▶
    • 7.1. Using Default Procedures
    • 7.2. Shortcut for Defining Simple Stored Procedures
    • 7.3. Verifying Expected Query Results
    • 7.4. Scheduling Stored Procedures as Tasks
    • 7.5. Directed Procedures: Distributing Transactions to Every Partition
  • 8. Using VoltDB with Other Programming Languages▶
    • 8.1. C++ Client Interface
      • 8.1.1. Writing VoltDB Client Applications in C++
      • 8.1.2. Creating a Connection to the Database Cluster
      • 8.1.3. Invoking Stored Procedures
      • 8.1.4. Invoking Stored Procedures Asynchronously
      • 8.1.5. Interpreting the Results
    • 8.2. JSON HTTP Interface
      • 8.2.1. How the JSON Interface Works
      • 8.2.2. Using the JSON Interface from Client Applications
      • 8.2.3. How Parameters Are Interpreted
      • 8.2.4. Interpreting the JSON Results
      • 8.2.5. Error Handling using the JSON Interface
      • 8.2.6. Managing Client Sessions
    • 8.3. JDBC Interface
      • 8.3.1. Using JDBC to Connect to a VoltDB Database
      • 8.3.2. Using JDBC to Query a VoltDB Database
  • 9. Integrating Volt Active Data with AI Agents and Chatbots▶
    • 9.1. Volt Agent Skills
      • 9.1.1. Installing Volt Skills
      • 9.1.2. Using Volt Skills Effectively
    • 9.2. The VoltDB MCP Server
      • 9.2.1. Installing the VoltDB MCP Server
      • 9.2.2. Configuring the MCP Server
      • 9.2.3. How to Use the VoltDB MCP Server
  • 10. Using VoltDB in a Cluster▶
    • 10.1. Starting a Database Cluster
    • 10.2. Defining the Cluster Configuration
    • 10.3. Elastic Scaling to Resize the Cluster
      • 10.3.1. Adding Nodes with Elastic Scaling
      • 10.3.2. Removing Nodes with Elastic Scaling
      • 10.3.3. Configuring How VoltDB Rebalances Nodes During Elastic Scaling
  • 11. Availability▶
    • 11.1. How K-Safety Works
    • 11.2. Enabling K-Safety
      • 11.2.1. What Happens When You Enable K-Safety
      • 11.2.2. Calculating the Appropriate Number of Nodes for K-Safety
    • 11.3. Recovering from System Failures
      • 11.3.1. What Happens When a Node Rejoins the Cluster
      • 11.3.2. Where and When Recovery May Fail
    • 11.4. Avoiding Network Partitions
      • 11.4.1. K-Safety and Network Partitions
      • 11.4.2. Network Fault Protection
  • 12. Active(N) Database Replication▶
    • 12.1. How Database Replication Works
      • 12.1.1. Starting Database Replication
      • 12.1.2. Database Replication, Availability, and Disaster Recovery
      • 12.1.3. Database Replication and Completeness
    • 12.2. Using Active(N) Cross Datacenter Replication
      • 12.2.1. Designing Your Schema for Active Replication
      • 12.2.2. Configuring the Database Clusters
      • 12.2.3. Starting the Database Clusters
      • 12.2.4. Loading a Matching Schema and Starting Replication
      • 12.2.5. Stopping Replication
      • 12.2.6. Example XDCR Configurations
      • 12.2.7. Understanding Conflict Resolution
    • 12.3. Updating the Schema During Replication
      • 12.3.1. Safely Updating the Schema While the Clusters are Paused
      • 12.3.2. Adding and Removing Tables Without Pausing
      • 12.3.3. Using Dynamic Schema Change to Add, Remove, and Modify Table Columns Without Pausing
    • 12.4. Monitoring Database Replication
    • 12.5. Tuning Active(N) to Meet Your Application Needs
      • 12.5.1. The XDCR Workflow
      • 12.5.2. Detecting and Correcting Bottlenecks in the XDCR Workflow
  • 13. Security▶
    • 13.1. How Security Works in VoltDB
    • 13.2. Enabling Authentication and Authorization
    • 13.3. Defining Users and Roles
    • 13.4. Assigning Access to Stored Procedures
    • 13.5. Assigning Access by Function (System Procedures, SQL Queries, and Default Procedures)
    • 13.6. Using Built-in Roles
    • 13.7. Encrypting VoltDB Communication Using TLS/SSL
      • 13.7.1. Creating the TLS/SSL Certificates
      • 13.7.2. Using Certificate Revocation Lists (CRLs)
      • 13.7.3. Configuring TLS/SSL on the VoltDB Server
      • 13.7.4. Configuring Mutual TLS/SSL on the Server and Clients
      • 13.7.5. Using the VoltDB Command Line Utilities with TLS/SSL
      • 13.7.6. Implementing TLS/SSL in the Java Client Applications
      • 13.7.7. Configuring Database Replication (XDCR) With TLS/SSL
      • 13.7.8. Updating TLS/SSL Certificates and Certificate Revocation Lists (CRLs)
    • 13.8. Integrating LDAP Security with VoltDB
      • 13.8.1. Configuring LDAP Security in VoltDB
      • 13.8.2. Configuring VoltDB Security in LDAP
    • 13.9. Integrating Kerberos Security with VoltDB
      • 13.9.1. Installing and Configuring Kerberos
      • 13.9.2. Configuring Java Security
      • 13.9.3. Configuring the VoltDB Servers and Clients
      • 13.9.4. Accessing the Database from the Command Line and the Web
  • 14. Saving & Restoring a VoltDB Database▶
    • 14.1. Performing a Manual Save and Restore of a VoltDB Cluster
      • 14.1.1. How to Save the Contents of a VoltDB Database
      • 14.1.2. How to Restore the Contents of a VoltDB Database Manually
      • 14.1.3. Changing the Cluster Configuration Using Save and Restore
    • 14.2. Scheduling Automated Snapshots
    • 14.3. Tuning the Snapshot Process
    • 14.4. Managing Snapshot Files
    • 14.5. Special Notes Concerning Save and Restore
  • 15. Command Logging and Recovery▶
    • 15.1. How Command Logging Works
    • 15.2. Controlling Command Logging
    • 15.3. Configuring Command Logging for Optimal Performance
      • 15.3.1. Log Size
      • 15.3.2. Log Frequency
      • 15.3.3. Synchronous vs. Asynchronous Logging
      • 15.3.4. Hardware Considerations
  • 16. Streaming Data: Import, Export, and Migration▶
    • 16.1. How Data Streaming Works in VoltDB
      • 16.1.1. Understanding Import
      • 16.1.2. Understanding Export
      • 16.1.3. Understanding Migration
      • 16.1.4. Understanding Topics
    • 16.2. The Business Case for Streaming Data
      • 16.2.1. Extract, Transform, Load (ETL)
      • 16.2.2. Change Data Capture
      • 16.2.3. Streaming Data Validation
      • 16.2.4. Caching
      • 16.2.5. Archiving
    • 16.3. VoltDB Export Connectors
      • 16.3.1. How Export Works
      • 16.3.2. The File Export Connector
      • 16.3.3. The HTTP Export Connector
      • 16.3.4. The JDBC Export Connector
      • 16.3.5. The Kafka Export Connector
      • 16.3.6. The Elasticsearch Export Connector
    • 16.4. VoltDB Import Connectors
      • 16.4.1. Bulk Loading Data Using VoltDB Standalone Utilities
      • 16.4.2. Streaming Import Using Built-in Import Features
      • 16.4.3. The Kafka Importer
    • 16.5. VoltDB Import Formatters
    • 16.6. VoltDB Topics
      • 16.6.1. Types of VoltDB Topics
      • 16.6.2. Declaring VoltDB Topics
      • 16.6.3. Configuring and Managing Topics
      • 16.6.4. Configuring the Topic Server
      • 16.6.5. Calling Topics from Consumers and Producers
      • 16.6.6. Using Opaque Topics
  • A. Supported SQL DDL Statements▶
    • ALTER STREAM
    • ALTER TABLE
    • ALTER TASK
    • ALTER VIEW
    • CREATE INDEX
    • CREATE PROCEDURE AS
    • CREATE PROCEDURE FROM CLASS
    • CREATE ROLE
    • CREATE STREAM
    • CREATE TABLE
    • CREATE TASK
    • CREATE VIEW
    • DR TABLE
    • DROP INDEX
    • DROP PROCEDURE
    • DROP ROLE
    • DROP STREAM
    • DROP TABLE
    • DROP TASK
    • DROP VIEW
    • PARTITION TABLE
  • B. Supported SQL Statements▶
    • DELETE
    • INSERT
    • MIGRATE
    • SELECT
    • TRUNCATE TABLE
    • UPDATE
    • UPSERT
  • C. SQL Functions▶
    • ABS()
    • APPROX_COUNT_DISTINCT()
    • AREA()
    • ARRAY_ELEMENT()
    • ARRAY_LENGTH()
    • ASTEXT()
    • AVG()
    • BIN()
    • BIT_SHIFT_LEFT()
    • BIT_SHIFT_RIGHT()
    • BITAND()
    • BITNOT()
    • BITOR()
    • BITXOR()
    • CAST()
    • CEILING()
    • CENTROID()
    • CHAR()
    • CHAR_LENGTH()
    • COALESCE()
    • CONCAT()
    • CONTAINS()
    • COS()
    • COT()
    • COUNT()
    • CSC()
    • CURRENT_DATE()
    • CURRENT_TIMESTAMP()
    • DATEADD()
    • DATEDIFF()
    • DAY(), DAYOFMONTH()
    • DAYOFWEEK()
    • DAYOFYEAR()
    • DECODE()
    • DEGREES()
    • DISTANCE()
    • DWITHIN()
    • EXP()
    • EXTRACT()
    • FIELD()
    • FLOOR()
    • FORMAT()
    • FORMAT_CURRENCY()
    • FORMAT_TIMESTAMP()
    • FROM_UNIXTIME()
    • HEX()
    • HOUR()
    • INET6_ATON()
    • INET6_NTOA()
    • INET_ATON()
    • INET_NTOA()
    • ISINVALIDREASON()
    • ISVALID()
    • IS_VALID_TIMESTAMP()
    • LATITUDE()
    • LEFT()
    • LN(), LOG()
    • LOG10()
    • LONGITUDE()
    • LOWER()
    • MAKEVALIDPOLYGON()
    • MAX()
    • MAX_VALID_TIMESTAMP()
    • MIGRATING()
    • MIN()
    • MIN_VALID_TIMESTAMP()
    • MINUTE()
    • MOD()
    • MONTH()
    • NOW()
    • NUMINTERIORRINGS()
    • NUMPOINTS()
    • OCTET_LENGTH()
    • OVERLAY()
    • PI()
    • POINTFROMTEXT()
    • POLYGONFROMTEXT()
    • POSITION()
    • POWER()
    • QUARTER()
    • RADIANS()
    • REGEXP_POSITION()
    • REPEAT()
    • REPLACE()
    • RIGHT()
    • ROUND()
    • SEC()
    • SECOND()
    • SET_FIELD()
    • SIGN()
    • SIN()
    • SINCE_EPOCH()
    • SPACE()
    • SQRT()
    • STR()
    • SUBSTRING()
    • SUM()
    • TAN()
    • TIME_WINDOW()
    • TO_TIMESTAMP()
    • TRIM()
    • TRUNCATE()
    • UPPER()
    • VALIDPOLYGONFROMTEXT()
    • WEEK(), WEEKOFYEAR()
    • WEEKDAY()
    • YEAR()
  • D. VoltDB CLI Commands▶
    • csvloader
    • jdbcloader
    • kafkaloader
    • sqlcmd
    • voltadmin
    • voltdb
  • E. YAML Configuration Properties▶
    • E.1. Understanding YAML Syntax
      • E.1.1. YAML Files
      • E.1.2. Dot Notation
    • E.2. YAML Properties for Configuring Volt Databases on Bare Metal
  • F. VoltDB Datatype Compatibility▶
    • F.1. Java and VoltDB Datatype Compatibility
  • G. System Procedures▶
    • @AdHoc
    • @AdjustLogging
    • @Explain
    • @ExplainProc
    • @ExplainView
    • @GetPartitionKeys
    • @GetYamlConfiguration
    • @Metrics
    • @Note
    • @Pause
    • @Ping
    • @Quiesce
    • @Resume
    • @SetYamlConfiguration
    • @Shutdown
    • @SnapshotDelete
    • @SnapshotRestore
    • @SnapshotSave
    • @SnapshotScan
    • @Statistics
    • @StopNode
    • @SwapTables
    • @SystemCatalog
    • @SystemInformation
    • @UpdateClasses
    • @UpdateLogging

sqlcmd

sqlcmd — Starts an interactive command prompt for issuing SQL queries to a running VoltDB database

Synopsis

sqlcmd [args...]

Description

The sqlcmd command lets you query a VoltDB database interactively. You can execute SQL statements, invoke stored procedures, or use directives to examine the structure of the database. When sqlcmd starts it provides its own command line prompt until you exit the session. When you start the session, you can optionally specify one or more database servers to access. By default, sqlcmd accesses the database on the local system via localhost.

At the sqlcmd prompt, you have several options:

  • SQL queries — You can enter ad hoc SQL queries that are run against the database and the results displayed. You must terminate the query with a semi-colon and carriage return.

  • Procedure calls — You can have sqlcmd execute a stored procedure. You identify a procedure call with the exec directive, followed by the procedure class name, the procedure parameters, and a closing semi-colon. For example, the following sqlcmd directive executes the @SystemCatalog system procedure requesting information about the stored procedures.

    $ sqlcmd
    1> exec @SystemCatalog procedures;

    Note that string values can be entered as plain text or enclosed in single quotation marks. Also, the exec directive must be terminated by a semi-colon.

  • Echo directives — The echo and echoerror directives let you add comments or informational messages to the sqlcmd output. Any text following the directive up to and including the line break or carriage return is repeated verbatim:

    • ECHO [text] — Writes the specified text, as is, to standard output (stdout).

    • ECHOERROR [text] — Writes the specified text, as is, to standard error (stderr).

  • Show, Describe, and Explain directives — The show, describe, and explain directives let you examine the structure of the schema and user-defined stored procedures. Valid directives are:

    • SHOW CLASSES — Lists the user-defined classes in the database. Classes are grouped into procedures classes (those that can be invoked as a stored procedure) and non-procedure classes (shared classes that cannot themselves be called as stored procedures but can be invoked from within stored procedures).

    • SHOW PROCEDURES — Lists the user-defined, default, and system procedures for the current database, including the type and number of arguments for each.

    • SHOW TABLES — Lists the tables in the schema.

    • DESCRIBE {table-name} — Lists the columns of a table, stream, or view.

    • EXPLAIN {sql-query} — Displays the execution plan for the specified SQL statement.

    • EXPLAINPROC {procedure-name} — Displays the execution plans for the specified stored procedure.

    • EXPLAINVIEW {view-name} — Displays the execution plans for the components of the specified view.

  • Class management directives — The load classes and remove classes directives let you add and remove Java classes from the database:

    • LOAD CLASSES —Loads any classes or resource files in the specified JAR file. If a class or resource already exists in the database, it is replaced by the new definition from the JAR file.

    • REMOVE CLASSES — Removes any classes that match the specified class name string. The class specification can include wildcards.

  • Command recall — You can recall previous commands using the up and down arrow keys. Or you can recall a specific command by line number (the command prompt shows the line number) using the recall command. For example:

    $ sqlcmd
    1> select * from votes;
    2> show procedures;
    3> recall 1
    select * from votes;

    Once recalled, you can edit the command before reissuing it using typical editing keys, such as the left and right arrow keys and backspace and delete.

  • Script files — You can run multiple queries or stored procedures in a single command using the file directive. The file directive takes one or more text files as an argument and executes all of the SQL queries and exec directives in the file(s) as if they were entered interactively. (Do not use control directives such as recall and exit in script files.) Separate multiple script files with spaces. Enclose file names that contain spaces with single quotation marks. For example, the first command in the following example processes all of the SQL queries and procedure invocations in the file myscript.sql. The second command processes the SQL queries from two files:

    $ sqlcmd
    1> file myscript.sql;
    2> file yourscript.sql 'their script.sql';

    If the file(s) contain only data definition language (DDL) statements, you can also have the files processed as a single batch by including the -batch argument:

    $ sqlcmd
    1> file -batch myscript.sql;

    If a file or set of statements includes both DDL and DML statements, you can still batch process a group of DDL statements by enclosing the statements in a file -inlinebatch directive and the specified end marker. For example, in the following code the three CREATE PROCEDURE statements are processed as a batch:

    load classes myprocs.jar;
    file -inlinebatch END_OF_BATCH
    CREATE PROCEDURE FROM CLASS procs.AddEmployee;
    CREATE PROCEDURE FROM CLASS procs.ChangeDept;
    CREATE PROCEDURE FROM CLASS procs.PromoteEmployee;
    END_OF_BATCH

    Batch processing the DDL statements has two effects:

    • Batch processing can significantly improve performance since all of the schema changes are processed and distributed to the cluster nodes at one time, rather than individually for each statement.

    • The batch operates as a transaction, succeeding or failing as a unit. If any statement fails, all of the schema changes are rolled back.

  • Exit — When you are done with your interactive session, enter the exit directive to end the session and return to the shell prompt.

To run a sqlcmd command without starting the interactive prompt, you can pipe the command through standard input to the sqlcmd command. For example:

$ echo "select * from contestants;" | sqlcmd

In general, the sqlcmd commands are not case sensitive and must be terminated by a semi-colon. However, the semi-colon is optional for the exit, file, and recall directives. Also, list and quit are supported as synonyms for the show and exit directives, respectively.

Textual Data and Character Sets

All text data in Volt is processed and stored as UTF-8 encoded strings. However, it is possible to enter and display data in other character sets if desired.

For interactive sessions, the sqlcmd utility automatically translates between the localized character set for the user's interactive session and UTF-8 used by Volt internally. For example, when executing an INSERT statement into a VARCHAR column, the text being inserted is converted from the localized character set into UTF-8 before being inserted. Similarly, when displaying results from a SELECT statement, text fields are converted from UTF-8 into the user's session character set before being sent to the terminal. The web-based Volt Management Console (VMC) provides a similar service automatically converting to and from the user's session character set to UTF-8 on input and output.

When processing data from a file, sqlcmd provides the --charset qualifier that lets you specify the character set used both for processing files for input (either with the --file qualifier or the FILE directive) and writing files for output (with the --output qualifier). You can also use the --charset qualifier with the csvloader utility to specify the character set of the CSV input file. Finally, the file export connector supports a charset property for specifying what character set to use when exporting data to a file. (See Table 16.1, “File Export Properties” for more information on the file export connector properties.)

Which character sets are supported depends on which Java virtual machine (JVM) release you are using on your servers (for export) or client machines (for sqlcmd and csvloader). For established character sets, such as Shift_JIS or ISO-8859-1, all supported JVM releases provide support. For newer character sets, you may need a more recent release of the JVM. For example, the recent Simplified Chinese character set GB18030-2022 requires a JVM released in 2023 or later. For OpenJDK this includes the following releases:

  • Java 8 — release 8u32-b05

  • Java 11 — release 11.0.20+8

  • Java 17 — release 17.0.8+7

Arguments

--batch

When used with the --file qualifier, processes the data definition language (DDL) statements in the file as a single batch (rather than one at a time) and returns to the shell prompt. Batch processing of DDL statements is orders of magnitude faster than processing each statement separately. However, the file must contain DDL statements only, no data manipulation language (DML) queries such as SELECT or INSERT. If the file contains both DDL and DML, use the file --inlinebatch directive in the file to delineate batches of DDL statements then process the file with the --file qualifier only.

--charset={character-set-name}

Specifies the character encoding to use when interpreting file input (using the --file qualifier or FILE directive) and when writing file output (using the --output-file qualifier). If no character set is specified, sqlcmd uses UTF-8 for file input and output. Note that the --charset qualifier does not affect text entered at the sqlcmd prompt, which is always interpreted using the session's default character set, as is also true of output displayed on the terminal.

--credentials={properties-file}

Specifies a file that lists the username and password of the account to use when connecting to a database with security enabled. This is useful when writing shell scripts because it avoids having to hardcode the password as plain text in the script. The credentials file is interpreted as a Java properties file defining the properties username and password. For example:

username: johndoe
password: 4tUn8

Because it is a Java properties file, you must escape certain special characters in the username or password, including the colon or equals sign.

--file={file-spec}

Executes the SQL statements in the specified file and then returns to the shell prompt.

--help

Displays the sqlcmd help text then returns to the shell prompt.

--kerberos={service-name}

Specifies the use of kerberos authentication when connecting to the database server(s). The service name identifies the Kerberos client service module, as defined by the JAAS login configuration file.

--output-file={file-spec}

Write the output from sqlcmd commands and statements to the specified file. Note that only the out of the commands are written to the file, errors and informational messages (such as how many rows were affected) are still written to the terminal. By default all output is written to the terminal.

--output-format={csv | fixed | tab}

Specifies the format of the output of query results. Output can be formatted as comma-separated values (csv), fixed monospaced text (fixed), or tab-separated text fields (tab). By default, the output is in fixed monospaced text.

--output-skip-metadata

Specifies that the column headings and other metadata associated with query results are not displayed. By default, the output includes such metadata. However, you can use this argument, along with the --output-format argument, to write just the data itself to an output file.

--port={port-num}

Specifies the port number to use when connecting to the database servers. All servers must be using the same port number. By default, sqlcmd connects to the standard client port (21212).

--query={text}

Submits the specified text as an SQL query to the database, displays the results and returns to the shell prompt.

--query-timeout={time-limit}

Specifies a time limit for read-only queries. Any read-only queries that exceed the time limit are canceled and control returned to the user. Specify the time out as an integer number of milliseconds. The default timeout is set in the cluster configuration (or set to 10 seconds by default). Only users with ADMIN privileges can set a sqlcmd timeout longer than the cluster-wide setting.

--servers={server-id}[,...]

Specifies the network address of one or more nodes in the database cluster. When specifying an IPv6 address, enclose the address in square brackets. By default, sqlcmd attempts to connect to a database on localhost.

--ssl[=ssl-config-file]

Specifies the use of TLS encryption when communicating with the server. Only necessary if the cluster is configured to use TLS encryption for the external ports. See the section called “Using CLI Commands with TLS/SSL” for more information.

--stop-on-error={true|false}

When processing file input (with the --file qualifier or the file directive) stops any further execution when an error occurs, if set to true. If false, the statement causing the error is ignored and processing continues to the next statement in the file. The default is true.

--user={user-id}

Specifies the username to use for authenticating to the database. The username is required if the database has security enabled.

--password={text}

Specifies the password to use when connecting to the database. You must specify a username and password if security is enabled for the database. If you specify a username with the --user argument but not the --password argument, VoltDB prompts for the password.

Example

The following example demonstrates an sqlcmd session, accessing the voter sample database running on node zeus.

$ sqlcmd --servers=zeus
SQL Command :: zeus:21212
1> select * from contestants;
 1 Edwina Burnam   
 2 Tabatha Gehling 
 3 Kelly Clauss    
 4 Jessie Alloway  
 5 Alana Bregman   
 6 Jessie Eichman  

(6 row(s) affected)
2> select sum(num_votes) as total, contestant_number from 
v_votes_by_contestant_number_State group by contestant_number 
order by total desc;
TOTAL   CONTESTANT_NUMBER 
------- ------------------
 757240                  1
 630429                  6
 442962                  5
 390353                  4
 384743                  2
 375260                  3


(6 row(s) affected)
3> exit
$
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.