What is Dolt

Version controlled SQL database

Dolt is a version controlled SQL database. Its versioning model and command line are based on git, and its SQL dialect and wire protocol are based on MySQL. If you know how to use the git command line, you know how to use the dolt command line. If your application works with MySQL, it will work with Dolt with no changes.

Example

The dolt command line copies git exactly. Let's use dolt clone to clone a database from DoltHub:
1
$ dolt clone dolthub/ip-to-country
2
cloning https://doltremoteapi.dolthub.com/dolthub/ip-to-country
3
32,832 of 32,832 chunks complete. 0 chunks being downloaded currently.
Copied!
After cloning the database, we can open a SQL shell on it.
1
$ cd ip-to-country
2
$ dolt sql
3
# Welcome to the DoltSQL shell.
4
# Statements must be terminated with ';'.
5
# "exit" or "quit" (or Ctrl-D) to exit.
6
ip_to_country> show tables;
7
+---------------+
8
| Table |
9
+---------------+
10
| IPv4ToCountry |
11
| IPv6ToCountry |
12
+---------------+
Copied!
Make changes to tables with SQL. Create a new branch with dolt checkout -b. Examine the diff with dolt diff. Stage changes with dolt add .. Commit changes with dolt commit. Push your changes back to the remote with dolt push origin master.
All the commands you know for git work exactly the same for dolt.
For more info, see the CLI docs.

Application server

If you want Dolt to back your application, start the MySQL-compatible server:
1
dolt sql-server
2
Starting server with Config HP="localhost:3306"|U="root"|P=""|T="28800000"|R="false"|L="info"
Copied!
Any tool or application that speaks the MySQL protocol can talk to the server. Here's the mysql shell:
1
~|>> mysql --host=127.0.0.1 --user=root
2
Welcome to the MySQL monitor. Commands end with ; or \g.
3
Your MySQL connection id is 1
4
Server version: 5.7.9-Vitess
5
6
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
7
8
Oracle is a registered trademark of Oracle Corporation and/or its
9
affiliates. Other names may be trademarks of their respective
10
owners.
11
12
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
13
14
mysql> use ip_to_country;
15
Reading table information for completion of table and column names
16
You can turn off this feature to get a quicker startup with -A
17
18
Database changed
19
mysql> show tables;
20
+---------------+
21
| Table |
22
+---------------+
23
| IPv4ToCountry |
24
| IPv6ToCountry |
25
+---------------+
26
2 rows in set (0.00 sec)
Copied!

Version control features in SQL

All of Dolt's version control features are exposed in SQL as well as on the command line. That means users can script complex version control workflows into the SQL queries that define data pipelines.

AS OF

Query previous revisions of any table with the AS OF syntax.
1
select * from IPv6ToCountry as of 'HEAD~';
Copied!

DOLT_COMMIT()

DOLT_COMMIT() in a SQL query works the same as dolt commit on the command line:
1
SELECT DOLT_COMMIT('-m', 'This is a commit', '--author', 'John Doe <[email protected]>');
Copied!
Most dolt commands are accessible in a similar manner, and others are exposed as system tables.
For more info, check out the SQL docs.
Last modified 23d ago