<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Cristian,<br><br>In PostGres, you can set up a new database scheme using a particular template. For spatial databases, you can create a template, so you don't have to add the postgis extensions or spatial reference systems each time you create a new spatial database. So you first create a new template for spatial databases that we call "template_postgis".<br><br>createdb template_postgis<br>$ createlang plpgsql template_postgis (plpgsql provides the functionality to use the spatial extensions)<br>$ psql -d template_postgis -f postgis/postgis.sql<br>$ psql -d template_postgis -f spatial_ref_sys.sql (contains the parameters of the various spatial reference systems, describing the projections and coordinate systems)<br><br>Next you grant the appropriate actions to the user "postgres".<br><br>$ psql -d template_postgis<br># grant select, update, insert, delete on table geometry_columns to postgres;<br># grant select on table spatial_ref_sys to postgres;<br>#\q<br><br>Since you do not want each database to be owned by postgres (just as you wouldn't want every directory in your file system to be owned by root), let's create a new user "gisuser":<br><br>$ createuser gisuser -P<br><br>Finally, you create your spatial database "gisdb" that is owned by the new user "gisuser". For this, you simply use the template that you created earlier "template_postgis". So, you create your template once and re-use every time you create a new spatial database, gisdb1, gisdb2, gisdb3 or a more explanatory database name. <br><br>$ createdb -T template_postgis -E UTF8 -O gisuser gisdb<br><br>Hope this helps.<br><br>Edward<br><br><br><br><hr id="stopSpelling">Date: Fri, 9 Apr 2010 12:10:47 +0200<br>From: vasileestan@gmail.com<br>To: postgis-users@postgis.refractions.net<br>Subject: [postgis-users] steps in creating a new database<br><br>Hi all,<br><br><br>I try to create a new postgis database on Ubuntu, and I'm quite confused about the steps in creating a database.<br><br><br>Creating database:<br># createdb -T [template] [name_of_the_database]<br><br>
- what are the use [-T] and [template] in this line <br>- I can create my own template? for example: # createdb -T [general_data] [world]<br><br>


        
        <title></title>
        
        <style>
@page
{;}
.ExternalClass P
{margin-bottom:0.08in;}
</style>

<p style="margin-bottom: 0in;">Adding plpsql language to the database:</p><p style="margin-bottom: 0in;">


        
        <title></title>
        
        <style>
@page
{;}
.ExternalClass P
{margin-bottom:0.08in;}
</style>

</p><p style="margin-bottom: 0in;"># createlang plpgsql [database]</p><p style="margin-bottom: 0in;">


        
        <title></title>
        
        <style>
@page
{;}
.ExternalClass P
{margin-bottom:0.08in;}
</style>

</p><p style="margin-bottom: 0in;"># psql -d [database] -f
/usr/share/postgresql/8.4/contrib/postgis.sql</p>

<p style="margin-bottom: 0in;"># psql -d [database] -f
/usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql</p>

<p style="margin-bottom: 0in;"># psql -d [database] -c"select
postgis_lib_version();"</p>
<BR>
<BR>
<br>- is plpgsql a condition in creating a geodatabase<br>- what's happening if I don't add this line # psql -d [database] -f
/usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql<br><br>- This are the complete steps in creating a spatial database? <br>- Where i can find more information regarding this subject?<br><br><br>Thank you, <br>Cristian<br>
<br>                                        </body>
</html>