sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
sudo systemctl status postgresql
sudo su postgres
psql
another way to access: sudo -i -u postgres
To access a Postgres prompt: psql
create database: create database db_name;
drop database: drop database db_name;
show database: \l
Current Database and User: \c postgres;
Example code:
CREATE TABLE weather (
city varchar(80),
temp_lo int, -- low temperature
temp_hi int, -- high temperature
prcp real, -- precipitation
date date
);
INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');