Shell-Befehle
Dot-Befehle, die in der interaktiven SQL-Shell von Turso verfügbar sind
Shell-Befehle
Dot-Befehle sind spezielle Befehle, die in der interaktiven Shell verfügbar sind. Sie beginnen mit einem Punkt (.) und erfordern kein abschließendes Semikolon.
tursodb> .help
Datenbank & Navigation
.open
Öffnet eine Datenbankdatei, optional mit Angabe eines VFS-Backends.
.open <PATH> [VFS]
tursodb> .open mydata.db
tursodb> .open mydata.db memory
.quit
Beendet die Shell. Aliase: .q, .qu, .qui.
tursodb> .quit
.exit
Beendet die Shell mit einem optionalen Rückgabecode. Aliase: .ex, .exi.
.exit [CODE]
tursodb> .exit
tursodb> .exit 1
.cd
Wechselt das aktuelle Arbeitsverzeichnis.
.cd <DIRECTORY>
tursodb> .cd /tmp
Schema-Inspektion
.tables
Listet alle Tabellen in der Datenbank auf, optional gefiltert nach einem Muster.
.tables [PATTERN]
CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE departments (id INTEGER PRIMARY KEY, name TEXT);
tursodb> .tables
employees
departments
tursodb> .tables emp%
employees
.schema
Zeigt die CREATE-Anweisung für eine Tabelle oder alle Tabellen an, wenn kein Argument angegeben wurde.
.schema [TABLE]
tursodb> .schema employees
CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT);
tursodb> .schema
CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE departments (id INTEGER PRIMARY KEY, name TEXT);
.indexes
Zeigt Indexnamen an, optional gefiltert nach Tabelle.
.indexes [TABLE]
CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT, department TEXT);
CREATE INDEX idx_dept ON employees(department);
CREATE INDEX idx_name ON employees(name);
tursodb> .indexes
idx_dept
idx_name
tursodb> .indexes employees
idx_dept
idx_name
.databases
Listet alle angehängten Datenbanken auf.
tursodb> .databases
main: /path/to/mydata.db r/w
Ausgabesteuerung
.mode
Legt den Anzeigemodus der Ausgabe fest.
.mode <MODE>
| Modus | Beschreibung |
|---|---|
pretty |
Tabelle mit Rahmen (Standard) |
list |
Pipe-getrennte Werte |
line |
Eine Spalte pro Zeile mit Spaltennamen |
tursodb> .mode list
tursodb> SELECT 1 AS a, 2 AS b;
1|2
tursodb> .mode line
tursodb> SELECT 1 AS a, 2 AS b;
a = 1
b = 2
tursodb> .mode pretty
tursodb> SELECT 1 AS a, 2 AS b;
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 2 │
└───┴───┘
.headers
Schaltet Spaltenüberschriften im list-Modus ein oder aus.
.headers <on|off>
tursodb> .mode list
tursodb> .headers on
tursodb> SELECT 1 AS x, 2 AS y;
x|y
1|2
tursodb> .headers off
tursodb> SELECT 1 AS x, 2 AS y;
1|2
.nullvalue
Legt die Zeichenkette fest, die im list-Modus für NULL-Werte angezeigt wird.
.nullvalue <STRING>
tursodb> .mode list
tursodb> .nullvalue [NULL]
tursodb> SELECT 1 AS a, NULL AS b;
1|[NULL]
.output
Leitet die Abfrageausgabe in eine Datei um. Ohne Argument oder mit stdout aufrufen, um die Ausgabe wieder im Terminal auszugeben.
.output [PATH]
tursodb> .output results.txt
tursodb> SELECT * FROM employees;
tursodb> .output
tursodb> -- Output is back to the terminal
.echo
Schaltet den Echo-Modus um. Wenn aktiviert, wird jede SQL-Anweisung vor der Ausführung ausgegeben.
.echo <on|off>
tursodb> .echo on
tursodb> SELECT 42;
SELECT 42;
┌────┐
│ 42 │
├────┤
│ 42 │
└────┘
.show
Zeigt die aktuellen Shell-Einstellungen an.
tursodb> .show
Settings:
Output mode: pretty
DB: mydata.db
Output: STDOUT
Null value:
CWD: /home/user
Echo: off
Headers: off
Performance & Diagnose
.timer
Schaltet die Abfragezeitmessung um. Wenn aktiviert, werden nach jeder Abfrage Ausführungszeit und I/O-Statistiken angezeigt.
.timer <on|off>
tursodb> .timer on
tursodb> SELECT 42;
42
Command stats:
----------------------------
total: 442 us (this includes parsing/coloring of cli app)
query execution stats:
----------------------------
Execution: avg=4 us, total=8 us
I/O: No samples available
.stats
Zeigt Datenbankstatistiken an. Mit on/off die automatische Anzeige nach jeder Abfrage umschalten oder mit --reset die Zähler zurücksetzen.
.stats [on|off] [--reset]
tursodb> .stats
Connection Metrics:
Total statements: 3
High-water marks:
Max VM steps: 19
Max rows read: 1
Aggregate Statistics:
Statement Metrics:
Row Operations:
Rows read: 1
Rows written: 2
Execution:
VM steps: 48
Instructions: 47
...
.opcodes
Zeigt Opcodes der VDBE (Virtual Database Engine) mit Beschreibungen an. Optional nach Opcode-Namen filtern.
.opcodes [OPCODE]
tursodb> .opcodes Integer
Integer
-------
The 64-bit integer value P1 is written into register P2. This is different
from SQLite, where this opcode is used for 32-bit integers
.vfslist
Listet verfügbare Virtual-File-System-Module auf.
tursodb> .vfslist
Available VFS modules:
memory
syscall
Datenimport & -export
.dump
Gibt die gesamte Datenbank als SQL-Anweisungen aus, mit denen sie neu erstellt werden kann.
tursodb> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT);
INSERT INTO "employees" VALUES(1,'Alice');
INSERT INTO "employees" VALUES(2,'Bob');
COMMIT;
Die Ausgabe von .dump kann per Pipe an eine andere Turso-Instanz übergeben werden, um die Datenbank neu zu erstellen:
tursodb original.db ".dump" | tursodb -q clone.db
.import
Importiert Daten aus einer Datei in eine Tabelle.
.import [--csv] [--skip N] [--verbose] <FILE> <TABLE>
| Option | Standard | Beschreibung |
|---|---|---|
--csv |
an | Komma als Feldtrennzeichen und Zeilenumbruch als Datensatztrennzeichen verwenden |
--skip N |
0 | Die ersten N Zeilen überspringen (nützlich zum Überspringen einer Kopfzeile) |
--verbose |
aus | Fortschrittsinformationen während des Imports ausgeben |
tursodb> CREATE TABLE people (name TEXT, age INTEGER);
tursodb> .import --csv --skip 1 data.csv people
tursodb> SELECT * FROM people;
┌─────────┬─────┐
│ name │ age │
├─────────┼─────┤
│ Alice │ 30 │
├─────────┼─────┤
│ Bob │ 25 │
├─────────┼─────┤
│ Charlie │ 35 │
└─────────┴─────┘
Angesichts einer CSV-Datei data.csv:
name,age
Alice,30
Bob,25
Charlie,35
.clone
Klont die aktuelle Datenbank in eine neue Datei.
.clone <OUTPUT_FILE>
tursodb> .clone backup.db
employees... done
.read
Führt SQL-Anweisungen aus einer Datei aus.
.read <PATH>
tursodb> .read setup.sql
.load
Lädt eine Erweiterungsbibliothek.
.load <PATH>
tursodb> .load ./liblimbo_regexp
Es können nur Turso-native Erweiterungen geladen werden. Ladbare SQLite-.so/.dll-Erweiterungen werden nicht unterstützt. Siehe die Dokumentation Extensions für verfügbare Erweiterungen.
Debugging
.dbtotxt
Zeigt den rohen Inhalt von Datenbankseiten im Hex-Format an. Nützlich zum Debuggen von Problemen auf Speicherebene.
.dbtotxt [--page PAGE_NO]
tursodb> .dbtotxt --page 1
| size 8192 pagesize 4096 filename :memory:
| page 1 offset 0
| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
| 16: 10 00 02 02 00 40 20 20 00 00 00 01 00 00 00 02 .....@ ........
...
.dbconfig
Gibt Datenbank-Konfigurationsflags aus oder legt sie fest. Derzeit ein No-op in Turso.
.dbconfig [CONFIG] [on|off]
Dokumentation
.manual
Zeigt integrierte Handbuchseiten für Turso-Funktionen an. Ohne Argument aufrufen, um alle verfügbaren Handbücher aufzulisten.
.manual [PAGE]
Aliase: .man.
tursodb> .manual
# Turso Manual Pages
Available manuals:
custom-types Custom Types for STRICT Tables
cdc Change Data Capture
encryption At-Rest Database Encryption
vector Vector Search
materialized-views Live Materialized Views
mcp Model Context Protocol server
tursodb> .manual vector