[postgis-users] steps in creating a new database

pcreso at pcreso.com pcreso at pcreso.com
Tue Apr 13 00:14:43 PDT 2010


Hi Vasile,

 createdb -T [template] [name_of_the_database]

This creates a new database in a working Postgres instalation.

The -T is an optional parameter allowing you to specify a template database to base the new one on. You can create a template database as a custom Postgres database with whatever special facilities you may desire to be automatically provided in a new database you create, by using it as the template. You do not need to use this to create a Postgis database (but you can if you so desire)

For example just use createdb dbname to create a new database called dbname.

A Postgres database newly created without specifyinfg a suitable custom template will not have support for the plpgsql language installed in the database. Postgis is basically written in this language, so you need to add it to the Postgres database before adding Postgis, using  createlang plpgsql [database]

You can add Postgis without running  
psql -d [database] -f
/usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql
but generally I would not. This command creates a table in the Postgis database called spatial_ref_sys, which contains information about standard projections to enable Postgis to transform (reproject) spatial objects from one datum/projection to another. 

These steps (along with  psql -d [database] -f
/usr/share/postgresql/8.4/contrib/postgis.sql)
will create a Postgis, or spatially enabled Postgres database which is capable of storing, querying & manipulating spatial objects (geometries), but will not create any geometries in the database. You have the facilities to manage spatial data, but have not yet added any such data to the new database.

The documentation available at www.postgis.org is a good place to start, and various books also provide information on using Postgis, including:

Web Mapping Illustrated: Using Open Source GIS Toolkits by Tyler Mitchell
PostGIS in Action by Regina and Leo Hsu (being written)
 

  
  
  
   Beginning MapServer: Open Source GIS Development by Bill Kropla
Desktop GIS: Mapping the Planet with Open Source Tools by Gary Sherman
Open Source Approaches in Spatial Data Handling (Advances in Geographic Information Science) by Brent Hall and Michael G. Leahy

HTH,

  Brent Wood

--- On Fri, 4/9/10, Vasile Cristian Stan <vasileestan at gmail.com> wrote:

From: Vasile Cristian Stan <vasileestan at gmail.com>
Subject: [postgis-users] steps in creating a new database
To: postgis-users at postgis.refractions.net
Date: Friday, April 9, 2010, 10:10 PM

Hi all,


I try to create a new postgis database on Ubuntu, and I'm quite confused about the steps in creating a database.


Creating database:
# createdb -T [template] [name_of_the_database]


- what are the use [-T] and [template] in this line 
- I can create my own template? for example: # createdb -T [general_data] [world]




	 
	
	 
	



Adding plpsql language to the database:


	 
	
	 
	



# createlang plpgsql [database]


	 
	
	 
	



# psql -d [database] -f
/usr/share/postgresql/8.4/contrib/postgis.sql

# psql -d [database] -f
/usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql

# psql -d [database] -c"select
postgis_lib_version();"



- is plpgsql a condition in creating a geodatabase
- what's happening if I don't add this line # psql -d [database] -f
/usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql

- This are the complete steps in creating a spatial database? 
- Where i can find more information regarding this subject?


Thank you, 
Cristian




-----Inline Attachment Follows-----

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100413/b6611de8/attachment.html>


More information about the postgis-users mailing list