1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044
|
<?xml version="1.0" encoding="UTF-8"?>
<sect1 id="Management_Functions">
<title>Management Functions</title>
<refentry id="AddGeometryColumn">
<refnamediv>
<refname>AddGeometryColumn</refname>
<refpurpose>Adds a geometry column to an existing table of
attributes. By default uses type modifier to define rather than constraints.
Pass in false for use_typmod to get old check constraint based behavior</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>AddGeometryColumn</function></funcdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>srid</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>type</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>dimension</parameter></paramdef>
<paramdef choice="opt"><type>boolean </type>
<parameter>use_typmod=true</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>AddGeometryColumn</function></funcdef>
<paramdef><type>varchar </type>
<parameter>schema_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>srid</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>type</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>dimension</parameter></paramdef>
<paramdef choice="opt"><type>boolean </type>
<parameter>use_typmod=true</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>AddGeometryColumn</function></funcdef>
<paramdef><type>varchar </type>
<parameter>catalog_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>schema_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>srid</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>type</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>dimension</parameter></paramdef>
<paramdef choice="opt"><type>boolean </type>
<parameter>use_typmod=true</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Adds a geometry column to an existing table of attributes. The
<varname>schema_name</varname> is the name of the table schema. The <varname>srid</varname>
must be an integer value reference to an entry in the SPATIAL_REF_SYS
table. The <varname>type</varname> must be a 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.</para>
<note>
<para>Changed: 2.0.0 This function no longer updates geometry_columns since geometry_columns is a view that reads from system catalogs. It by default
also does not create constraints, but instead uses the built in type modifier behavior of PostgreSQL. So for example building a wgs84 POINT column with this function is now
equivalent to: <code>ALTER TABLE some_table ADD COLUMN geom geometry(Point,4326);</code> </para>
<para>Changed: 2.0.0 If you require the old behavior of constraints use the default <varname>use_typmod</varname>, but set it to false.</para>
</note>
<note>
<para>Changed: 2.0.0 Views can no longer be manually registered in geometry_columns, however views built against geometry typmod tables geometries and used without wrapper functions will register themselves correctly
because they inherit the typmod behavior of their parent table column.
Views that use geometry functions that output other geometries will need to be cast to typmod geometries for these view geometry columns to be registered correctly
in geometry_columns. Refer to <xref linkend="Manual_Register_Spatial_Column"/>.
</para>
</note>
<para>&sfs_compliant;</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
<para>Enhanced: 2.0.0 use_typmod argument introduced. Defaults to creating typmod geometry column instead of constraint-based.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>-- Create schema to hold data
CREATE SCHEMA my_schema;
-- Create a new simple PostgreSQL table
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
SELECT AddGeometryColumn ('my_schema','my_spatial_table','geom',4326,'POINT',2);
-- Add a point using the old constraint based behavior
SELECT AddGeometryColumn ('my_schema','my_spatial_table','geom_c',4326,'POINT',2, false);
--Add a curvepolygon using old constraint behavior
SELECT AddGeometryColumn ('my_schema','my_spatial_table','geomcp_c',4326,'CURVEPOLYGON',2, false);
-- Describe the table again reveals the addition of a new geometry columns.
\d my_schema.my_spatial_table
addgeometrycolumn
-------------------------------------------------------------------------
my_schema.my_spatial_table.geomcp_c SRID:4326 TYPE:CURVEPOLYGON DIMS:2
(1 row)
Table "my_schema.my_spatial_table"
Column | Type | Modifiers
----------+----------------------+-------------------------------------------------------------------------
id | integer | not null default nextval('my_schema.my_spatial_table_id_seq'::regclass)
geom | geometry(Point,4326) |
geom_c | geometry |
geomcp_c | geometry |
Check constraints:
"enforce_dims_geom_c" CHECK (st_ndims(geom_c) = 2)
"enforce_dims_geomcp_c" CHECK (st_ndims(geomcp_c) = 2)
"enforce_geotype_geom_c" CHECK (geometrytype(geom_c) = 'POINT'::text OR geom_c IS NULL)
"enforce_geotype_geomcp_c" CHECK (geometrytype(geomcp_c) = 'CURVEPOLYGON'::text OR geomcp_c IS NULL)
"enforce_srid_geom_c" CHECK (st_srid(geom_c) = 4326)
"enforce_srid_geomcp_c" CHECK (st_srid(geomcp_c) = 4326)
-- geometry_columns view also registers the new columns --
SELECT f_geometry_column As col_name, type, srid, coord_dimension As ndims
FROM geometry_columns
WHERE f_table_name = 'my_spatial_table' AND f_table_schema = 'my_schema';
col_name | type | srid | ndims
----------+--------------+------+-------
geom | Point | 4326 | 2
geom_c | Point | 4326 | 2
geomcp_c | CurvePolygon | 4326 | 2
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="DropGeometryColumn"/>, <xref linkend="DropGeometryTable"/>, <xref linkend="geometry_columns"/>, <xref linkend="Manual_Register_Spatial_Column"/></para>
</refsection>
</refentry>
<refentry id="DropGeometryColumn">
<refnamediv>
<refname>DropGeometryColumn</refname>
<refpurpose>Removes a geometry column from a spatial
table.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>DropGeometryColumn</function></funcdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>DropGeometryColumn</function></funcdef>
<paramdef><type>varchar </type>
<parameter>schema_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>DropGeometryColumn</function></funcdef>
<paramdef><type>varchar </type>
<parameter>catalog_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>schema_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>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.</para>
<para>&sfs_compliant;</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
<note>
<para>Changed: 2.0.0 This function is provided for backward compatibility. Now that since geometry_columns is now a view against the system catalogs,
you can drop a geometry column like any other table column using <code>ALTER TABLE</code></para>
</note>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
SELECT DropGeometryColumn ('my_schema','my_spatial_table','geom');
----RESULT output ---
dropgeometrycolumn
------------------------------------------------------
my_schema.my_spatial_table.geom effectively removed.
-- In PostGIS 2.0+ the above is also equivalent to the standard
-- the standard alter table. Both will deregister from geometry_columns
ALTER TABLE my_schema.my_spatial_table DROP column geom;
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="AddGeometryColumn"/>, <xref linkend="DropGeometryTable"/>, <xref linkend="geometry_columns"/></para>
</refsection>
</refentry>
<refentry id="DropGeometryTable">
<refnamediv>
<refname>DropGeometryTable</refname>
<refpurpose>Drops a table and all its references in
geometry_columns.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>DropGeometryTable</function></funcdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>boolean <function>DropGeometryTable</function></funcdef>
<paramdef><type>varchar </type>
<parameter>schema_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>boolean <function>DropGeometryTable</function></funcdef>
<paramdef><type>varchar </type>
<parameter>catalog_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>schema_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Drops a table and all its references in geometry_columns. Note:
uses current_schema() on schema-aware pgsql installations if schema is
not provided.</para>
<note>
<para>Changed: 2.0.0 This function is provided for backward compatibility. Now that since geometry_columns is now a view against the system catalogs,
you can drop a table with geometry columns like any other table using <code>DROP TABLE</code></para>
</note>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT DropGeometryTable ('my_schema','my_spatial_table');
----RESULT output ---
my_schema.my_spatial_table dropped.
-- The above is now equivalent to --
DROP TABLE my_schema.my_spatial_table;
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="AddGeometryColumn"/>, <xref linkend="DropGeometryColumn"/>, <xref linkend="geometry_columns"/></para>
</refsection>
</refentry>
<refentry id="PostGIS_Full_Version">
<refnamediv>
<refname>PostGIS_Full_Version</refname>
<refpurpose>Reports full postgis version and build configuration
infos.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_Full_Version</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Reports full postgis version and build configuration
infos. Also informs about synchronization between
libraries and scripts suggesting upgrades as needed.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_Full_Version();
postgis_full_version
----------------------------------------------------------------------------------
POSTGIS="2.2.0dev r12699" GEOS="3.5.0dev-CAPI-1.9.0 r3989" SFCGAL="1.0.4" PROJ="Rel. 4.8.0, 6 March 2012"
GDAL="GDAL 1.11.0, released 2014/04/16" LIBXML="2.7.8" LIBJSON="0.12" RASTER
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para>
<xref linkend="upgrading" />,
<xref linkend="PostGIS_GEOS_Version" />,
<xref linkend="PostGIS_Lib_Version" />,
<xref linkend="PostGIS_LibXML_Version" />,
<xref linkend="PostGIS_PROJ_Version" />,
<xref linkend="PostGIS_Version" />
</para>
</refsection>
</refentry>
<refentry id="PostGIS_GEOS_Version">
<refnamediv>
<refname>PostGIS_GEOS_Version</refname>
<refpurpose>Returns the version number of the GEOS
library.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_GEOS_Version</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the version number of the GEOS library, or
<varname>NULL</varname> if GEOS support is not enabled.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_GEOS_Version();
postgis_geos_version
----------------------
3.1.0-CAPI-1.5.0
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Full_Version" />, <xref
linkend="PostGIS_Lib_Version" />, <xref
linkend="PostGIS_LibXML_Version" />, <xref
linkend="PostGIS_PROJ_Version" />, <xref
linkend="PostGIS_Version" /></para>
</refsection>
</refentry>
<refentry id="PostGIS_LibXML_Version">
<refnamediv>
<refname>PostGIS_LibXML_Version</refname>
<refpurpose>Returns the version number of the libxml2
library.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_LibXML_Version</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the version number of the LibXML2 library.</para>
<para>Availability: 1.5</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_LibXML_Version();
postgis_libxml_version
----------------------
2.7.6
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Full_Version" />, <xref
linkend="PostGIS_Lib_Version" />, <xref
linkend="PostGIS_PROJ_Version" />, <xref
linkend="PostGIS_GEOS_Version" />, <xref
linkend="PostGIS_Version" /></para>
</refsection>
</refentry>
<refentry id="PostGIS_Lib_Build_Date">
<refnamediv>
<refname>PostGIS_Lib_Build_Date</refname>
<refpurpose>Returns build date of the PostGIS library.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_Lib_Build_Date</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns build date of the PostGIS library.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_Lib_Build_Date();
postgis_lib_build_date
------------------------
2008-06-21 17:53:21
(1 row)</programlisting>
</refsection>
</refentry>
<refentry id="PostGIS_Lib_Version">
<refnamediv>
<refname>PostGIS_Lib_Version</refname>
<refpurpose>Returns the version number of the PostGIS
library.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_Lib_Version</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the version number of the PostGIS library.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_Lib_Version();
postgis_lib_version
---------------------
1.3.3
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Full_Version" />, <xref
linkend="PostGIS_GEOS_Version" />, <xref
linkend="PostGIS_LibXML_Version" />, <xref
linkend="PostGIS_PROJ_Version" />, <xref
linkend="PostGIS_Version" /></para>
</refsection>
</refentry>
<refentry id="PostGIS_PROJ_Version">
<refnamediv>
<refname>PostGIS_PROJ_Version</refname>
<refpurpose>Returns the version number of the PROJ4
library.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_PROJ_Version</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the version number of the PROJ4 library, or
<varname>NULL</varname> if PROJ4 support is not enabled.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_PROJ_Version();
postgis_proj_version
-------------------------
Rel. 4.4.9, 29 Oct 2004
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Full_Version" />, <xref
linkend="PostGIS_GEOS_Version" />, <xref
linkend="PostGIS_Lib_Version" />, <xref
linkend="PostGIS_LibXML_Version" />, <xref
linkend="PostGIS_Version" /></para>
</refsection>
</refentry>
<refentry id="PostGIS_Scripts_Build_Date">
<refnamediv>
<refname>PostGIS_Scripts_Build_Date</refname>
<refpurpose>Returns build date of the PostGIS scripts.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_Scripts_Build_Date</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns build date of the PostGIS scripts.</para>
<para>Availability: 1.0.0RC1</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_Scripts_Build_Date();
postgis_scripts_build_date
-------------------------
2007-08-18 09:09:26
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Full_Version" />, <xref
linkend="PostGIS_GEOS_Version" />, <xref
linkend="PostGIS_Lib_Version" />, <xref
linkend="PostGIS_LibXML_Version" />, <xref
linkend="PostGIS_Version" /></para>
</refsection>
</refentry>
<refentry id="PostGIS_Scripts_Installed">
<refnamediv>
<refname>PostGIS_Scripts_Installed</refname>
<refpurpose>Returns version of the postgis scripts installed in this
database.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_Scripts_Installed</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns version of the postgis scripts installed in this
database.</para>
<note>
<para>If the output of this function doesn't match the output of
<xref linkend="PostGIS_Scripts_Released" />
you probably missed to properly upgrade an existing database.
See the <link linkend="upgrading">Upgrading</link> section for
more info.</para>
</note>
<para>Availability: 0.9.0</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_Scripts_Installed();
postgis_scripts_installed
-------------------------
1.5.0SVN
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Full_Version" />, <xref linkend="PostGIS_Scripts_Released" />, <xref linkend="PostGIS_Version" /></para>
</refsection>
</refentry>
<refentry id="PostGIS_Scripts_Released">
<refnamediv>
<refname>PostGIS_Scripts_Released</refname>
<refpurpose>Returns the version number of the postgis.sql script
released with the installed postgis lib.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_Scripts_Released</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the version number of the postgis.sql script
released with the installed postgis lib.</para>
<note>
<para>Starting with version 1.1.0 this function returns the same
value of <xref linkend="PostGIS_Lib_Version" />. Kept
for backward compatibility.</para>
</note>
<para>Availability: 0.9.0</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_Scripts_Released();
postgis_scripts_released
-------------------------
1.3.4SVN
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Full_Version" />, <xref linkend="PostGIS_Scripts_Installed" />, <xref linkend="PostGIS_Lib_Version" /></para>
</refsection>
</refentry>
<refentry id="PostGIS_Version">
<refnamediv>
<refname>PostGIS_Version</refname>
<refpurpose>Returns PostGIS version number and compile-time
options.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>PostGIS_Version</function></funcdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns PostGIS version number and compile-time options.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT PostGIS_Version();
postgis_version
---------------------------------------
1.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="PostGIS_Full_Version" />, <xref
linkend="PostGIS_GEOS_Version" />, <xref
linkend="PostGIS_Lib_Version" />, <xref
linkend="PostGIS_LibXML_Version" />, <xref
linkend="PostGIS_PROJ_Version" /></para>
</refsection>
</refentry>
<refentry id="Populate_Geometry_Columns">
<refnamediv>
<refname>Populate_Geometry_Columns</refname>
<refpurpose>Ensures geometry columns are defined with type modifiers or have appropriate spatial constraints
This ensures they will be registered correctly in <varname>geometry_columns</varname> view. By default will convert all geometry
columns with no type modifier to ones with type modifiers. To get old behavior set <varname>use_typmod=false</varname></refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>Populate_Geometry_Columns</function></funcdef>
<paramdef><type>boolean </type> <parameter>use_typmod=true</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>Populate_Geometry_Columns</function></funcdef>
<paramdef><type>oid</type> <parameter>relation_oid</parameter></paramdef>
<paramdef><type>boolean </type> <parameter>use_typmod=true</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Ensures geometry columns have appropriate type modifiers or spatial constraints to ensure they are registered correctly in <varname>geometry_columns</varname> table.</para>
<para>For backwards compatibility and for spatial needs such as table inheritance where each child table may have different geometry type, the old check constraint behavior is still supported.
If you need the old behavior, you need to pass in the new optional argument as false <varname>use_typmod=false</varname>. When this is done geometry columns will be created with no type modifiers
but will have 3 constraints defined. In particular,
this means that every geometry column belonging to a table has at least
three constraints:</para>
<itemizedlist>
<listitem>
<para><varname>enforce_dims_the_geom</varname> - ensures every
geometry has the same dimension (see <xref
linkend="ST_NDims" />)</para>
</listitem>
<listitem>
<para><varname>enforce_geotype_the_geom</varname> - ensures every
geometry is of the same type (see <xref
linkend="GeometryType" />)</para>
</listitem>
<listitem>
<para><varname>enforce_srid_the_geom</varname> - ensures every
geometry is in the same projection (see <xref
linkend="ST_SRID" />)</para>
</listitem>
</itemizedlist>
<para>If a table <varname>oid</varname> is provided, this function
tries to determine the srid, dimension, and geometry type of all
geometry columns in the table, adding constraints 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.</para>
<para>If the <varname>oid</varname> 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 <varname>geometry_columns</varname> table, but nothing is done
to enforce constraints.</para>
<para>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
constraints 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 <varname>geometry_columns</varname> table. The
parameterized version simply returns the number of rows inserted into
the <varname>geometry_columns</varname> table.</para>
<para>Availability: 1.4.0</para>
<para>Changed: 2.0.0 By default, now uses type modifiers instead of check constraints to constrain geometry types. You can still use check
constraint behavior instead by using the new <varname>use_typmod</varname> and setting it to false.</para>
<para>Enhanced: 2.0.0 <varname>use_typmod</varname> optional argument was introduced that allows controlling if columns are created with typmodifiers or with check constraints.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
CREATE TABLE public.myspatial_table(gid serial, geom geometry);
INSERT INTO myspatial_table(geom) VALUES(ST_GeomFromText('LINESTRING(1 2, 3 4)',4326) );
-- This will now use typ modifiers. For this to work, there must exist data
SELECT Populate_Geometry_Columns('public.myspatial_table'::regclass);
populate_geometry_columns
--------------------------
1
\d myspatial_table
Table "public.myspatial_table"
Column | Type | Modifiers
--------+---------------------------+---------------------------------------------------------------
gid | integer | not null default nextval('myspatial_table_gid_seq'::regclass)
geom | geometry(LineString,4326) |
</programlisting>
<programlisting>-- This will change the geometry columns to use constraints if they are not typmod or have constraints already.
--For this to work, there must exist data
CREATE TABLE public.myspatial_table_cs(gid serial, geom geometry);
INSERT INTO myspatial_table_cs(geom) VALUES(ST_GeomFromText('LINESTRING(1 2, 3 4)',4326) );
SELECT Populate_Geometry_Columns('public.myspatial_table_cs'::regclass, false);
populate_geometry_columns
--------------------------
1
\d myspatial_table_cs
Table "public.myspatial_table_cs"
Column | Type | Modifiers
--------+----------+------------------------------------------------------------------
gid | integer | not null default nextval('myspatial_table_cs_gid_seq'::regclass)
geom | geometry |
Check constraints:
"enforce_dims_geom" CHECK (st_ndims(geom) = 2)
"enforce_geotype_geom" CHECK (geometrytype(geom) = 'LINESTRING'::text OR geom IS NULL)
"enforce_srid_geom" CHECK (st_srid(geom) = 4326)</programlisting>
</refsection>
<!--
<refsection>
<title>See Also</title>
<para><xref linkend="Probe_Geometry_Columns" /></para>
</refsection>
-->
</refentry>
<refentry id="UpdateGeometrySRID">
<refnamediv>
<refname>UpdateGeometrySRID</refname>
<refpurpose>Updates the SRID of all features in a geometry
column, geometry_columns metadata and srid. If it was enforced with constraints, the constraints will be updated with new srid constraint.
If the old was enforced by type definition, the type definition will be changed.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>UpdateGeometrySRID</function></funcdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>srid</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>UpdateGeometrySRID</function></funcdef>
<paramdef><type>varchar </type>
<parameter>schema_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>srid</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>UpdateGeometrySRID</function></funcdef>
<paramdef><type>varchar </type>
<parameter>catalog_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>schema_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>table_name</parameter></paramdef>
<paramdef><type>varchar </type>
<parameter>column_name</parameter></paramdef>
<paramdef><type>integer </type>
<parameter>srid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>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.</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<para>This will change the srid of the roads table to 4326 from whatever it was before</para>
<programlisting>SELECT UpdateGeometrySRID('roads','geom',4326);</programlisting>
<para>The prior example is equivalent to this DDL statement</para>
<programlisting>ALTER TABLE roads
ALTER COLUMN geom TYPE geometry(MULTILINESTRING, 4326)
USING ST_SetSRID(geom,4326);</programlisting>
<para>If you got the projection wrong (or brought it in as unknown) in load and you wanted to transform to web mercator all in one shot
You can do this with
DDL but there is no equivalent PostGIS management function to do so in one go.</para>
<programlisting>ALTER TABLE roads
ALTER COLUMN geom TYPE geometry(MULTILINESTRING, 3857) USING ST_Transform(ST_SetSRID(geom,4326),3857) ;</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para>
<xref linkend="RT_UpdateRasterSRID"/>,
<xref linkend="ST_SetSRID"/>,
<xref linkend="ST_Transform"/>
</para>
</refsection>
</refentry>
</sect1>
|