gpt4 book ai didi

postgresql - 如何在 postgres ubuntu 中检查 postgis 的模板

转载 作者:行者123 更新时间:2023-12-04 19:20:12 25 4
gpt4 key购买 nike

我正在关注本教程

http://technobytz.com/install-postgis-postgresql-9-3-ubuntu.html

我用这个命令创建了数据库
createdb test_db -T template_postgis2.1
但我得到这个错误

test_db2=# select postgis_version();
ERROR: function postgis_version() does not exist
LINE 1: select postgis_version();

如果使用,这有效
create extension postgis
我想知道那没关系,或者我有错误。因为我之前做过模板。该模板不是自动将数据库设置为 postgis

最佳答案

根据official documentation on the topic ,您必须在您创建的每个新数据库中创建扩展。为什么?这与数据库在 PostgreSQL-9.1+ 和 PostGIS-2+ 中启用 PostGIS 的方式发生了变化有关。以前,必须运行一系列脚本才能将 PostGIS 的功能、类型和其他特性加载到数据库中。因此,最佳实践是创建一个模板数据库(template_postgis 等),针对该模板运行所有脚本,并针对该模板创建每个启用 PostGIS 的新数据库。在较新版本的 PostgreSQL (9.1+) 中,您只需执行命令 CREATE EXTENSION postgis 即可在新数据库中启用 PostGIS 支持。 ;因此,您应该完全跳过模板步骤。

所以总结一下:

  • CREATE EXTENSION postgis;是 PostgreSQL-9.1+ 和 PostGIS-2+
  • 的方法
  • 制作模板数据库是 PostgreSQL 或 PostGIS 早期版本的方法。

  • 我希望这有助于清除它!

    关于postgresql - 如何在 postgres ubuntu 中检查 postgis 的模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22368806/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com