</answer>
</qandaentry>
- <qandaentry>
+ <qandaentry id="faq_how_to_define_geometry_table">
<question>
<para>How do I insert a GIS object into the database?</para>
</question>
For geometry: Connect to your database with
<filename>psql</filename> and try the following SQL:</para>
- <programlisting>CREATE TABLE gtest ( ID int4, NAME varchar(20) );
-SELECT AddGeometryColumn('', 'gtest','geom',-1,'LINESTRING',2);</programlisting>
+ <programlisting>CREATE TABLE gtest ( gid serial primary key, name varchar(20)
+ , geom geometry(LINESTRING) );</programlisting>
- <para>If the geometry column addition fails, you probably have not
- loaded the PostGIS functions and objects into this database. See the
+ <para>If the geometry column definition fails, you probably have not
+ loaded the PostGIS functions and objects into this database or are using a pre-2.0 version of PostGIS. See the
<xref linkend="PGInstall" />.</para>
<para>Then, you can insert a geometry into the table using a SQL
VALUES (
1,
'First Geometry',
- ST_GeomFromText('LINESTRING(2 3,4 5,6 5,7 8)', -1)
+ ST_GeomFromText('LINESTRING(2 3,4 5,6 5,7 8)')
);</programlisting>
<para>For more information about other GIS objects, see the <link