Install Postgresql

aptitude install postgresql

Setup Postgresql

su root
su postgres

psql template1

\l

\q

Create Users

su root
su postgres

createuser myusername -P
Enter password for new role: ******
Enter it again:  ******
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n

Create Database

psql template1

CREATE DATABASE somedatabase;

GRANT ALL PRIVILEGES ON DATABASE somedatabase to myusername;

Using Postgres

List Databases

\l

List tables

\dt

Describe tables

\d sometablename

Count rows in table

SELECT COUNT (*) FROM tablename;

Install postgresql postgis

aptitude install postgresql-8.3-postgis
or
aptitude install postgresql-8.x-postgis (x is your version)

Enable postgis functions

vi /usr/share/doc/postgresql-8.3-postgis/README.Debian.gz 

su root
su postgres

psql template1
CREATE DATABASE somedatabase;
createuser myusername -P
GRANT ALL PRIVILEGES ON DATABASE somedatabase to myusername;

createlang plpgsql -d somedatabase

psql somedatabase -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql
psql somedatabase -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql

grant all on geometry_columns to myusername;
grant select on spatial_ref_sys to myusername;

Log out. Log back in with your username and see if the functions are there. dt to list tables and df to list functions in postgre sql:

\dt
\df

MyWiki: Postgresql (last edited 2009-09-06 02:49:21 by localhost)