LinuxCommandLibrary

dolt-sql

Execute SQL queries against Dolt databases

TLDR

Run a single query

$ dolt sql [[-q|--query]] "[INSERT INTO t values (1, 3);]"
copy

List all saved queries
$ dolt sql [[-l|--list-saved]]
copy

SYNOPSIS

dolt sql [--version] [--help] [--format ] [--file ] [--query ] [--user ] [--password ] [--host ] [--port ] [--socket ] [--data-dir ] [--config ] []

PARAMETERS

--version
    Show application version.

--help
    Show help message.

--format
    The format to use for displaying query results. Options: table, csv, json, json-pretty.

--file
    Execute SQL statements from a file.

--query
    Execute a single SQL query.

--user
    MySQL user to connect with.

--password
    MySQL password to connect with.

--host
    MySQL host to connect to.

--port
    MySQL port to connect to.

--socket
    MySQL socket to connect to.

--data-dir
    Path to the Dolt data directory.

--config
    Path to the Dolt configuration file.


    The Dolt database to connect to.

DESCRIPTION

The `dolt sql` command provides a SQL command-line interface to interact with Dolt databases. Dolt extends MySQL's storage engine to enable Git-like functionality, such as branching, versioning, and merging, for relational data. This command allows users to query, update, and manage Dolt databases using standard SQL syntax, while also leveraging Dolt's unique features related to data version control. You can connect to local or remote Dolt databases, execute SQL queries, import and export data, and manage Dolt's branching and merging capabilities through SQL or specific dolt commands. It bridges the gap between SQL and Git, enabling powerful workflows for data management and collaboration. Data audits and lineage tracking become significantly easier.

USAGE EXAMPLES

Connect to a Dolt database:
dolt sql mydatabase

Execute a SQL query directly:
dolt sql --query "SELECT * FROM mytable;" mydatabase

Execute SQL queries from a file:
dolt sql --file queries.sql mydatabase

SEE ALSO

dolt(1), dolt_clone(1), dolt_branch(1)

Copied to clipboard