Tuesday, August 11, 2009

PostgreSQL 8.4.0 Setup Complete




The Installation process was very straightforward and provided no surprises. Simply go to www.postgreSQL.org and download release 8.4. Run the installer and it should be very easy. A windows service called "PostgreSQL Server 8.4" will be created and can be verified by checking Control Panel, Administrative Tools, Services. If it does not start automatically, simply right click on it and select Start.



Once the database is running, connect to it and create a 'tradingbot' database.


C:\temp>psql -U postgres
Password for user postgres:
psql (8.4.0)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.

postgres=# create database tradebot;
CREATE DATABASE
postgres=# \l
List of databases
Name | Owner | Encoding | Collation | Ctype
| Access privileges
-----------+----------+----------+----------------------------+-----------------
-----------+-----------------------
postgres | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
template0 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres

: postgres=CTc/postgres
template1 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres

: postgres=CTc/postgres
tradebot | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
(4 rows)

postgres=# create user master with password 'blaster';
CREATE ROLE
postgres=# grant all on database tradebot to master;
GRANT
postgres=# \q

Line 1: Connect to default database
Line 9: Create database "tradebot"
Line 27: Create new user called "master"
Line 29: Grant privileges to "master"

Next step is to log into the new database and create a test table.


C:\temp>psql -d tradebot -U master
Password for user master:
psql (8.4.0)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.

tradebot=>\d
No relations found.
tradebot=> create table tester (id varchar(10) not null);
CREATE TABLE
tradebot=> \d
List of relations
Schema | Name | Type | Owner
--------+--------+-------+--------
public | tester | table | master
(1 row)


tradebot=> \d tester
Table "public.tester"
Column | Type | Modifiers
--------+-----------------------+-----------
id | character varying(10) | not null


tradebot=>

Line 1: Connect to tradebot database
Line 9: Get listing of all tables in the database. None returned because database is empty.
Line 11: Create "tester" table
Line 13: Get listing of all tables in the database. "Tester" table appears.
Line 21: Get "tester" table information

No comments: