Postgresql 9.3 Installation in Ubuntu 13.10

Since the usual PostgreSQL’s Personal Package Archives (PPA) has been deprecated in favour of a newer APT repository, is times for me to switch the repository and upgrade my installation to the latest-greatest version.

Surprisingly, there is a quicker and convenient way to install or upgrade your PostgreSQL. Let’s start with this method first.

Download the shell script, make it executable, and run it.
$ wget http://anonscm.debian.org/loggerhead/pkg-postgresql/postgresql-common/trunk/download/head:/apt.postgresql.org.s-20130224224205-px3qyst90b3xp8zj-1/apt.postgresql.org.sh
$ chmod +x apt.postgresql.org.sh
$ sudo ./apt.postgresql.org.sh

Remember, don’t simply download any shell script from the Net without actually peeking it source. One interesting thing I learned from the script is there are many ways to determine the code name of your Ubuntu/Debian distro. The simplest way is using lsb_release.
$ lsb_release -cs
saucy

Search for the latest available PostgreSQL versions, which as shown below is version 9.3.
$ apts ^postgresql-9.? | sort -r | head -n 1
postgresql-9.3-slony1-2 - replication system for PostgreSQL: PostgreSQL 9.3 server plug-in

Let’s us install the latest version, 9.3 and along with PgAdmin, the administrative tool.
$ sudo apt-get install postgresql-9.3 pgadmin3

Create and setup a local user account.
$ echo $USER
kianmeng

$ sudo -u postgres createuser --superuser $USER
$ sudo -u postgres psql
postgres=# \password kianmeng
postgres=# \q

$ createdb $USER

Finally, install the sample booktown database.
$ cd /tmp
$ wget http://www.commandprompt.com/ppbook/booktown.sql
$ sudo -u postgres psql -f booktown.sql template1

$ psql
psql (9.3.3)
Type "help" for help.

kianmeng=# \c booktown
You are now connected to database "booktown" as user "kianmeng".
booktown=# \dt
                 List of relations
 Schema |         Name          | Type  |  Owner
--------+-----------------------+-------+----------
 public | alternate_stock       | table | postgres
 public | authors               | table | postgres
 public | book_backup           | table | postgres
 public | book_queue            | table | postgres
 public | books                 | table | postgres
 public | customers             | table | postgres
 public | daily_inventory       | table | postgres
 public | distinguished_authors | table | postgres
 public | editions              | table | postgres
 public | employees             | table | postgres
 public | favorite_authors      | table | postgres
 public | favorite_books        | table | postgres
 public | money_example         | table | postgres
 public | my_list               | table | postgres
 public | numeric_values        | table | postgres
 public | publishers            | table | postgres
 public | schedules             | table | postgres
 public | shipments             | table | postgres
 public | states                | table | postgres
 public | stock                 | table | postgres
 public | stock_backup          | table | postgres
 public | subjects              | table | postgres
 public | text_sorting          | table | postgres
(23 rows)

booktown=#

No comments:

Post a Comment