Skip to main content Link Search Menu Expand Document (external link)

What is a database

Place where you can

  • Store
  • Manipulate
  • Retrieve

data

Postgress is the database Relationa

SQL is a language to speak to the the database exa

SELECT column FROM table_name

Data stored i tables has rows and colums row: data inside the tables column: fields

Relational database Relation between one or more tables a Information is split into different tables and a relation is created

PostgreSQL Open Source

Commands

Once inside psql or pgcli

  • \? gives me all available backlash commands
  • \q allows me to quit
  • \l lists all the databases

lowercase and uppercase dont matter

CREATE DATABASE waa;

To access it can either be in the command line

pgcli -h localhost -p 5432 -u user -d database

Or inside postgres with \c database

Create db: CREATE DATABASE name; Delete (dangerous): DROP DATABASE name;

CREATE TABLE table_name (
  Column_name + data_type + constraints,
)

Datatypes can be found here E.g.

CREATE TABLE person (
  id int,
  first_name VARCHAR(50),
  birthday TIMESTAMP
)

To show all tables, we can use /d as describe of /d name to describe a table