# Management Functions

AddGeometryColumn Adds a geometry column to an existing table of attributes.
text `AddGeometryColumn` varchar table_name varchar column_name integer srid varchar type integer dimension text `AddGeometryColumn` varchar schema_name varchar table_name varchar column_name integer srid varchar type integer dimension text `AddGeometryColumn` varchar catalog_name varchar schema_name varchar table_name varchar column_name integer srid varchar type integer dimension

### Description

Adds a geometry column to an existing table of attributes. The `schema_name` is the name of the table schema (unused for pre-schema PostgreSQL installations). The `srid` must be an integer value reference to an entry in the SPATIAL_REF_SYS table. The `type` must be an uppercase string corresponding to the geometry type, eg, 'POLYGON' or 'MULTILINESTRING'. An error is thrown if the schemaname doesn't exist (or not visible in the current search_path) or the specified SRID, geometry type, or dimension is invalid.

Views and derivatively created spatial tables will need to be registered in geometry_columns manually, since AddGeometryColumn also adds a spatial column which is not needed when you already have a spatial column. Refer to .

&sfs_compliant;

&Z_support;

&curve_support;

### Examples

    -- Create a new simple PostgreSQL table
    postgis=# CREATE TABLE my_schema.my_spatial_table (id serial);

    -- Describing the table shows a simple table with a single "id" column.
    postgis=# \d my_schema.my_spatial_table
    							 Table "my_schema.my_spatial_table"
     Column |  Type   |                                Modifiers
    --------+---------+-------------------------------------------------------------------------
     id     | integer | not null default nextval('my_schema.my_spatial_table_id_seq'::regclass)

    -- Add a spatial column to the table
    postgis=# SELECT AddGeometryColumn ('my_schema','my_spatial_table','the_geom',4326,'POINT',2);

    --Add a curvepolygon
    SELECT AddGeometryColumn ('my_schema','my_spatial_table','the_geomcp',4326,'CURVEPOLYGON',2);

    -- Describe the table again reveals the addition of a new "the_geom" column.
    postgis=# \d my_schema.my_spatial_table
       Column   |   Type   |                                Modifiers

    ------------+----------+-------------------------------------------------------------------------
     id         | integer  | not null default nextval('my_schema.my_spatial_table_id_seq'::regclass)
     the_geom   | geometry |
     the_geomcp | geometry |
    Check constraints:
    	"enforce_dims_the_geom" CHECK (ndims(the_geom) = 2)
    	"enforce_dims_the_geomcp" CHECK (ndims(the_geomcp) = 2)
    	"enforce_geotype_the_geom" CHECK (geometrytype(the_geom) = 'POINT'::text OR
    the_geom IS NULL)
    	"enforce_geotype_the_geomcp" CHECK (geometrytype(the_geomcp) = 'CURVEPOLYGON
    '::text OR the_geomcp IS NULL)
    	"enforce_srid_the_geom" CHECK (srid(the_geom) = 4326)
    	"enforce_srid_the_geomcp" CHECK (srid(the_geomcp) = 4326)

### See Also

, ,

DropGeometryColumn Removes a geometry column from a spatial table.
text `DropGeometryColumn` varchar table_name varchar column_name text `DropGeometryColumn` varchar schema_name varchar table_name varchar column_name text `DropGeometryColumn` varchar catalog_name varchar schema_name varchar table_name varchar column_name

### Description

Removes a geometry column from a spatial table. Note that schema_name will need to match the f_table_schema field of the table's row in the geometry_columns table.

&sfs_compliant;

&Z_support;

&curve_support;

### Examples

    			SELECT DropGeometryColumn ('my_schema','my_spatial_table','the_geomcp');
    			----RESULT output ---
    			my_schema.my_spatial_table.the_geomcp effectively removed.

### See Also

,

DropGeometryTable Drops a table and all its references in geometry_columns.
boolean `DropGeometryTable` varchar table_name boolean `DropGeometryTable` varchar schema_name varchar table_name boolean `DropGeometryTable` varchar catalog_name varchar schema_name varchar table_name

### Description

Drops a table and all its references in geometry_columns. Note: uses current_schema() on schema-aware pgsql installations if schema is not provided.

### Examples

    			SELECT DropGeometryTable ('my_schema','my_spatial_table');
    			----RESULT output ---
    			my_schema.my_spatial_table dropped.

### See Also

,

PostGIS_Full_Version Reports full postgis version and build configuration infos.
text `PostGIS_Full_Version`

### Description

Reports full postgis version and build configuration infos.

### Examples

    SELECT PostGIS_Full_Version();
    							   postgis_full_version
    ----------------------------------------------------------------------------------
     POSTGIS="1.3.3" GEOS="3.1.0-CAPI-1.5.0" PROJ="Rel. 4.4.9, 29 Oct 2004" USE_STATS
    (1 row)

### See Also

, , , ,

PostGIS_GEOS_Version Returns the version number of the GEOS library.
text `PostGIS_GEOS_Version`

### Description

Returns the version number of the GEOS library, or `NULL` if GEOS support is not enabled.

### Examples

    SELECT PostGIS_GEOS_Version();
     postgis_geos_version
    ----------------------
     3.1.0-CAPI-1.5.0
    (1 row)

### See Also

, , , ,

PostGIS_LibXML_Version Returns the version number of the libxml2 library.
text `PostGIS_LibXML_Version`

### Description

Returns the version number of the LibXML2 library.

Availability: 1.5

### Examples

    SELECT PostGIS_LibXML_Version();
     postgis_libxml_version
    ----------------------
     2.7.6
    (1 row)

### See Also

, , , ,

PostGIS_Lib_Build_Date Returns build date of the PostGIS library.
text `PostGIS_Lib_Build_Date`

### Description

Returns build date of the PostGIS library.

### Examples

    SELECT PostGIS_Lib_Build_Date();
     postgis_lib_build_date
    ------------------------
     2008-06-21 17:53:21
    (1 row)

PostGIS_Lib_Version Returns the version number of the PostGIS library.
text `PostGIS_Lib_Version`

### Description

Returns the version number of the PostGIS library.

### Examples

    SELECT PostGIS_Lib_Version();
     postgis_lib_version
    ---------------------
     1.3.3
    (1 row)

### See Also

, , , ,

PostGIS_PROJ_Version Returns the version number of the PROJ4 library.
text `PostGIS_PROJ_Version`

### Description

Returns the version number of the PROJ4 library, or `NULL` if PROJ4 support is not enabled.

### Examples

    SELECT PostGIS_PROJ_Version();
      postgis_proj_version
    -------------------------
     Rel. 4.4.9, 29 Oct 2004
    (1 row)

### See Also

, , , ,

PostGIS_Scripts_Build_Date Returns build date of the PostGIS scripts.
text `PostGIS_Scripts_Build_Date`

### Description

Returns build date of the PostGIS scripts.

Availability: 1.0.0RC1

### Examples

    SELECT PostGIS_Scripts_Build_Date();
      postgis_scripts_build_date
    -------------------------
     2007-08-18 09:09:26
    (1 row)

### See Also

, , , ,

PostGIS_Scripts_Installed Returns version of the postgis scripts installed in this database.
text `PostGIS_Scripts_Installed`

### Description

Returns version of the postgis scripts installed in this database.

If the output of this function doesn't match the output of you probably missed to properly upgrade an existing database. See the Upgrading section for more info.

Availability: 0.9.0

### Examples

    SELECT PostGIS_Scripts_Installed();
      postgis_scripts_installed
    -------------------------
     1.5.0SVN
    (1 row)

### See Also

, ,

PostGIS_Scripts_Released Returns the version number of the postgis.sql script released with the installed postgis lib.
text `PostGIS_Scripts_Released`

### Description

Returns the version number of the postgis.sql script released with the installed postgis lib.

Starting with version 1.1.0 this function returns the same value of . Kept for backward compatibility.

Availability: 0.9.0

### Examples

    SELECT PostGIS_Scripts_Released();
      postgis_scripts_released
    -------------------------
     1.3.4SVN
    (1 row)

### See Also

, ,

PostGIS_Uses_Stats Returns `TRUE` if STATS usage has been enabled.
text `PostGIS_Uses_Stats`

### Description

Returns `TRUE` if STATS usage has been enabled, `FALSE` otherwise.

### Examples

    SELECT PostGIS_Uses_Stats();
     postgis_uses_stats
    --------------------
     t
    (1 row)

### See Also

PostGIS_Version Returns PostGIS version number and compile-time options.
text `PostGIS_Version`

### Description

Returns PostGIS version number and compile-time options.

### Examples

    SELECT PostGIS_Version();
    			postgis_version
    ---------------------------------------
     1.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
    (1 row)

### See Also

, ,, ,

Populate_Geometry_Columns Ensures geometry columns have appropriate spatial constraints and exist in the `geometry_columns` table.
text `Populate_Geometry_Columns` int `Populate_Geometry_Columns` oid relation_oid

### Description

Ensures geometry columns have appropriate spatial constraints and exist in the `geometry_columns` table. In particular, this means that every geometry column belonging to a table has at least three constraints:

- `enforce_dims_the_geom` - ensures every geometry has the same dimension (see )

- `enforce_geotype_the_geom` - ensures every geometry is of the same type (see )

- `enforce_srid_the_geom` - ensures every geometry is in the same projection (see )

If a table `oid` is provided, this function tries to determine the srid, dimension, and geometry type of all geometry columns in the table, adding contraints as necessary. If successful, an appropriate row is inserted into the geometry_columns table, otherwise, the exception is caught and an error notice is raised describing the problem.

If the `oid` of a view is provided, as with a table oid, this function tries to determine the srid, dimension, and type of all the geometries in the view, inserting appropriate entries into the `geometry_columns` table, but nothing is done to enforce contraints.

The parameterless variant is a simple wrapper for the parameterized variant that first truncates and repopulates the geometry_columns table for every spatial table and view in the database, adding spatial contraints to tables where appropriate. It returns a summary of the number of geometry columns detected in the database and the number that were inserted into the `geometry_columns` table. The parameterized version simply returns the number of rows inserted into the `geometry_columns` table.

Availability: 1.4.0

### Examples

    SELECT Populate_Geometry_Columns('public.myspatial_table'::regclass);

### See Also

Probe_Geometry_Columns Scans all tables with PostGIS geometry constraints and adds them to the `geometry_columns` table if they are not there.
text `Probe_Geometry_Columns`

### Description

Scans all tables with PostGIS geometry constraints and adds them to the `geometry_columns` table if they are not there. Also give stats on number of inserts and already present or possibly obsolete.

This will usually only pick up records added by AddGeometryColumn() function. It will not scan views so views will need to be manually added to geometry_columns table.

### Examples

    SELECT Probe_Geometry_Columns();
    			probe_geometry_columns
    ---------------------------------------
    probed:6 inserted:0 conflicts:6 stale:0
    (1 row)

### See Also

UpdateGeometrySRID Updates the SRID of all features in a geometry column, geometry_columns metadata and srid table constraint
text `UpdateGeometrySRID` varchar table_name varchar column_name integer srid text `UpdateGeometrySRID` varchar schema_name varchar table_name varchar column_name integer srid text `UpdateGeometrySRID` varchar catalog_name varchar schema_name varchar table_name varchar column_name integer srid

### Description

Updates the SRID of all features in a geometry column, updating constraints and reference in geometry_columns. Note: uses current_schema() on schema-aware pgsql installations if schema is not provided.

&Z_support;

&curve_support;

### See Also