Using the REPL

Execute a query. To execute a query in the REPL, terminate the statement with a semicolon and press “ENTER”.


1. db>


1. select 5;


1. {5}

Alternatively, you can run the query without a semicolon by hitting Alt-Enter on Windows/Linux, or Esc+Return on macOS.


1. db>


1. select 5


1. {5}

Type Alt-Enter to run the query without having the cursor to the end of the query.

This doesn’t work by default on macOS, however it’s possible to enable it with a quick fix.

  • in Terminal.app: Settings → Profiles → Keyboard → Check “Use Option as Meta key”
  • in iTerm: Settings → Profiles → Keys → Let Option key: ESC+

Alternatively you can use the esc+return shortcut.

Use query parameters. If your query contains a parameter, you will be prompted for a value.


1. db>


1. select 5 + <int64>$num;


1. Parameter <int64>$num: 6
2. {11}

Commands

Options -v = verbose -s = show system objects -I = case-sensitive match
\d [-v] NAME Describe a schema object.
\ds, \describe schema Describe the entire schema.
\list databases alias: \l List databases.
\list scalars [-sI] [pattern] alias: \ls List scalar types.
\list types [-sI] [pattern] alias: \lt List object types.
\list roles [-I] alias: \lr List roles.
\list modules [-I] alias: \lm List modules.
\list aliases [-Isv] [pattern] alias: \la List expression aliases.
\list casts [-I] [pattern] alias: \lc List casts.
\list indexes [-Isv] [pattern] alias: \li List indexes.
\dump <filename> Dump the current database to file.
\restore <filename> Restore the database from a dump file.
\s, \history Show query history
\e, \edit [N] Spawn $EDITOR to edit history entry N. Then use the output as the input.
\set [<option> [<value>]] View/change a setting. Type \set to see all available settings.
\c, \connect [<dbname>] Connect to a particular database.

Sample usage

List databases:


1. db>


1. \ls


1. List of databases:
2. db
3. tutorial

Connect to a database:


1. db>


1. \c my_new_project


1. my_new_project>

Describe an object type:


1. db>


1. \d object Object


1. abstract type std::Object extending std::BaseObject {
2. required single link __type__ -> schema::Type {
3. readonly := true;
4. };
5. required single property id -> std::uuid {
6. readonly := true;
7. };
8. };

Describe a scalar type:


1. db>


1. \d object decimal


1. scalar type std::decimal extending std::anynumeric;

Describe a function:


1. db>


1. \d object sum


1. function std::sum(s: set of std::bigint) ->  std::bigint {
2. volatility := 'Immutable';
3. annotation std::description := 'Return the sum of the set of numbers.';
4. using sql function 'sum'
5. ;};
6. function std::sum(s: set of std::int32) ->  std::int64 {
7. volatility := 'Immutable';
8. annotation std::description := 'Return the sum of the set of numbers.';
9. using sql function 'sum'
10. ;};
11. function std::sum(s: set of std::decimal) ->  std::decimal {
12. volatility := 'Immutable';
13. annotation std::description := 'Return the sum of the set of numbers.';
14. using sql function 'sum'
15. ;};
16. function std::sum(s: set of std::float32) ->  std::float32 {
17. volatility := 'Immutable';
18. annotation std::description := 'Return the sum of the set of numbers.';
19. using sql function 'sum'
20. ;};
21. function std::sum(s: set of std::int64) ->  std::int64 {
22. volatility := 'Immutable';
23. annotation std::description := 'Return the sum of the set of numbers.';
24. using sql function 'sum'
25. ;};
26. function std::sum(s: set of std::float64) ->  std::float64 {
27. volatility := 'Immutable';
28. annotation std::description := 'Return the sum of the set of numbers.';
29. using sql function 'sum'
30. ;};