PostgreSQL Ubuntu

Install PostgreSQL

Easiest way to install is to use apt-get

sudo apt-get install postgresql

If you want to use latest version, specific version for postgresql, need some techniques
In my case, I tried following env

  • postgresql 9.5
  • Ubuntu 15.10

The instruction details are postgresql

Add /etc/apt/sources.list.d/postgresql.list
And add list, and install key and update

deb http://apt.postgresql.org/pub/repos/apt/ wily-pgdg main 9.5
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
  sudo apt-key add -
sudo apt-get update

You can download postgresql 9.5

sudo apt-get install postgresql-9.5

Start and Stop check

After install

ps aux | grep postgres

Stop

sudo /etc/init.d/posgresql stop

Start

sudo /etc/init.d/posgresql start

Acceess

sudo -u postgresql psql

Basic use

Database list

¥l

Connect database

¥c databasename

Table list

¥dt

Table detail

¥d tablename