Step 4: Make queries with the shell
The output of
turso db create in the last step shows a command to run to start
an interactive shell:
turso db shell my-db
Connected to my-db at libsql://my-db-[my-github-name].turso.io
Welcome to Turso SQL shell!
Type ".quit" to exit the shell, ".tables" to list all tables, and ".schema" to show table schemas.
See that the shell is working with a simple "hello world" SQL statement:
→ select "hello world" as message;
The shell requires that SQL commands terminate with a semicolon. If you enter a string that does not, the shell will continue accepting lines of SQL input until a terminating semicolon is provided.
Turso is backed by libSQL, which is a fork of SQLite, so you must provide SQL commands in the SQLite dialect.
Create and populate a table, and view its contents by copying the following SQL statements into the shell:
→ create table users (id text, email text);
→ insert into users values ("001", "firstname.lastname@example.org");
→ select * from users;
The shell reminds you of some the commands
.schema to inspect
the structure of the database:
CREATE TABLE users (id text, email text)
.quit or CTRL-d ends the shell.