The prompt
Editing a statement, recalling the last one, the rule that decides whether an answer is a table, and the shorthands that stand for statements.
tessaridb with no script to run gives you a prompt. It is the same prompt
whether the store is in this process or in another one, because both paths reach
the same renderer:
$ tessaridb --at 127.0.0.1:7654
tessaridb>
A statement ends at ;, and until then the prompt keeps taking lines — so a
long SELECT can be pasted or typed across as many lines as it needs. A ;
inside a string or a comment does not end anything.
Editing what you are typing
← → | a character |
Ctrl-B Ctrl-F | the same two, without leaving the home row |
Home End · Ctrl-A Ctrl-E | the ends of the line |
Ctrl-W | the word behind the cursor |
Ctrl-K Ctrl-U | to the end · to the beginning |
Ctrl-L | clear the screen, keeping what you have typed |
↑ ↓ | the statements this session has run |
Ctrl-C | throw away the statement being typed — the session stays |
Ctrl-D | leave, on an empty line |
The line scrolls sideways rather than wrapping when a statement is wider than the terminal.
History is this session only and is never written to disk. That is a
decision rather than a missing feature: DEFINE USER … PASSWORD '…' is a
statement like any other, so a history file is a file of credentials, and it
would be the one place a password outlives the process that was given it.
The terminal is handed back
Whatever ends the session — .exit, Ctrl-D, an error, a panic — the terminal
is put back the way it was found. A program that leaves a terminal in raw mode
leaves the shell broken after it, with no echo and no Ctrl-C, and the person
it happens to has no obvious way to connect that to the database they just
closed.
How an answer is drawn
Records that share one flat set of fields are drawn as an aligned table. Anything else keeps the document form:
tessaridb> SELECT * FROM users;
id | active | name | visits
----+--------+------------+--------
1 | true | 'ada' | 12
2 | false | 'grace' | 3
3 | true | 'margaret' | 1204
(3 record(s), via scan)
tessaridb> SELECT * FROM notes;
1: { body: 'a note', tags: ['one', 'two'] }
(1 record(s), via scan)
The second is not a table because tags is an array, and a cell holding
['one', 'two'] is a rendering that reads as a value the store does not have.
The rule is deliberately agreement, not union: if one record has a field the
others lack, the answer stays a document. A union with blanks would make
absent and empty look identical, and the rendering is the last place a
distinction should be lost.
Numbers are right-aligned; everything else is left-aligned.
You can insist either way:
tessaridb> .mode table
tessaridb> .mode document
tessaridb> .mode auto
A script gets the document form by default, whatever a terminal would have
done — piped or run with -e or -f — because that form is TessariQL you can
paste back into a statement, and a table is not. It is a default and not a
prohibition: .mode is read in a script exactly as it is at a prompt, so a
script that wants the table asks for it.
Shorthands
Every one of them runs a statement you could have typed, and prints it beside
itself in .help so that using one teaches the language rather than hiding it:
| shorthand | runs |
|---|---|
.ns | INFO FOR STORE; |
.db | INFO FOR NAMESPACE; |
.tables | INFO FOR DATABASE; |
.d <table> | INFO FOR TABLE <table>; |
.users | INFO FOR USERS; |
.user <name> | INFO FOR USER <name>; |
.node | INFO FOR NODE; |
A shorthand saves typing and never reaches anything a statement cannot. It
carries the same authority too — .users from a viewer is refused exactly as
INFO FOR USERS would be, because it is that statement by the time anything
executes.
One that needs a name and is given none is not a shorthand, and neither is one
that takes no name and is given one: .d alone and .tables users are both
left alone rather than guessed at.
The other dot commands
.help | the table above, and the editing keys |
.mode | how records are drawn |
.timing | print how long each script took |
.exit · .quit | leave |
.timing reports the round trip when the store is a node, because that is the
number that decides whether a query is slow from where you are sitting — not
the number the node would report about itself.
A refusal does not end the session
At a prompt, a refusal prints its message and the next statement runs. In a script it stops, and the exit code says so. The two are different on purpose: a person at a prompt has just learned something and is about to try again, and a migration that carries on past a failed statement is a migration nobody can reason about afterwards.
Next
- Users and access — who may run what, and how to change it.
- The web console — the same statements from a browser.
- The command line — every argument the binary takes.