gpt4 book ai didi

postgresql - "PostGIS Error: type “geography”不存在”使用psql时

转载 作者:行者123 更新时间:2023-11-29 12:15:29 24 4
gpt4 key购买 nike

我正在创建一个 .sql 文件来创建一个新数据库。我的几个表正在使用 Postgis 扩展。当我尝试从命令行创建数据库时:

psql location < location.sql

它在包含地理数据类型的列的表上失败。当我 psql 进入数据库时​​:

psql location

并从我的 .sql 文件中复制粘贴创建表代码,它可以很好地创建表。我觉得我在这里错过了一个小而重要的步骤

我一直在摆弄我的 .sql 文件,但没有运气解决这个错误

这是我用来创建数据库的脚本:

dropdb location
createdb location
psql -d location -c "CREATE EXTENSION postgis;"
psql -d location -c "CREATE EXTENSION postgis_topology;"
psql location < location.sql

这里是 location.sql 文件中失败的表的片段:

create table public.fips (
fips_id bigserial,
state_code char(2),
county_code char(3),
county_subdivision_code char(5),
place_code char(5),
consolidated_city_code char(5),
longitude double precision,
latitude double precision,
geo_point geography,
area_name text,
PRIMARY KEY (fips_id)
);

geo_point 是它提示的那个。

最佳答案

原来我需要在 geography 数据类型前加上 public。

关于postgresql - "PostGIS Error: type “geography”不存在”使用psql时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56668705/

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