Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Terminal

Joy Arulraj edited this page Jan 7, 2016 · 16 revisions

Introduction

Pelonton's interactive terminal allows you to interactively enter, edit, and execute SQL commands. It is very similar to the psql program in Postgres.

Helper shell script

Here is a shell script that you can use to bootstrap peloton easily.

Here are the steps you need to follow to get access to a terminal :

Create a data directory (if needed)

cd build
initdb ./data

We use initdb to create a new database cluster which is a collection of databases that are managed by a single Peloton server instance. Here, ./data is the location of the data directory for this new database cluster. All the tables and indices in any database that is part of this cluster will be stored in this directory.

Start the Peloton server

pg_ctl -D ./data start

pg_ctl is a program that can be used to start, stop, and control a Peloton server. It is installed along with Peloton, by default in usr/local/peloton/bin. Here, we use it to start the server.

Create a default user

createuser -s -r postgres

We need to create a default user using createuser utility. This can be used to add more users as well. We can also create a new database foo like this.

createdb foo

Connect to the server

psql postgres
help

Finally, we can connect to the Peloton server using the psql terminal utility. Here, we connect to the postgres database. We can also connect to any other database in the cluster by altering this command. To get a list of psql shortcuts, just type help and then press enter.

Stop the server

pg_ctl -D ./data stop

Now, we can use pg_ctl to stop the server.

Load in a SQL script and run it is psql

psql (9.5devel)
Type "help" for help.

parallels=# \i ../scripts/testing/join/nested_loop_join.sql 

More info on the terminal

PSQL manual
PSQL common usage

Clone this wiki locally