Tutorial: Native CedarDB
This tutorial explains how to run the native CedarDB binary.
CedarDB supports two modes of operation: server
and interactive
.
Get the binary
Interested in running CedarDB? Join our waitlist and be among the first to get access to CedarDB!
Interactive
Interactive mode launches a SQL shell to work directly with a database.
To create a new database and open it:
./cedardb --interactive --createdb mydb
If you’ve already created the database before:
./cedardb --interactive mydb
To create a temporary in-memory database:
./cedardb --interactive
This launches an ephemeral database that disappears once CedarDB exits.
In the shell, you can run SQL directly:
create table example(i int);
insert into example values (42);
For full syntax details, see the SQL Reference.
The REPL supports the common readline keyboard shortcuts (e.g., CTRL + R to search the history) and backslash commands:
\i schema_definition.sql -- Run commands from a file
\? -- View available commands
Server
Interactive mode is great for testing, but for longer-term use, you’ll want to run CedarDB as a PostgreSQL-compatible server.
By default (without the –interactive flag), CedarDB starts in server mode, allowing external connections.
After the initial startup, the CedarDB server does not allow arbitrary connections.
To start the server (assuming a database already exists):
./cedardb mydb
If the database doesn’t exist yet:
./cedardb -createdb mydb
Initially, the server only accepts connections via local domain socket from the same OS user:
psql -h /tmp -U postgres
Then, you can manage DB users via SQL:
create user test superuser with password '1234'; -- Or use fine-grained privileges
create database test;
To accept external connections, run:
./cedardb mydb/test.db --address=::
Then connect locally or remotely:
psql -h localhost -U test
psql -h cedardb.example.com -U test
For an overview of further options, run
./cedardb --help