我有以下简单表:
CREATE TABLE tbl_test
(
id serial NOT NULL,
poly polygon NOT NULL
)
WITH (OIDS=FALSE);
Run Code Online (Sandbox Code Playgroud)
然后我尝试插入一个带有多边形的行:
insert into tbl_test values(1, PolyFromText('POLYGON((0 0, 10 10, 10 0, 0 0))'))
Run Code Online (Sandbox Code Playgroud)
并遇到这个错误:
列"poly"的类型为polygon,但expression的类型为geometry
哪个是蹩脚的.所以我的第一个问题是:
无论如何,在投射后它起作用.现在我正在尝试做一个简单的ST_Contains查询:
select id, poly from tbl_test where ST_Contains(poly, Point(GeomFromText('POINT(9 2)')))
Run Code Online (Sandbox Code Playgroud)
这给出了错误:
ERROR: function st_contains(polygon, point) does not exist
LINE 1: select id, poly from tbl_test where ST_Contains(poly, Point(...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts. …Run Code Online (Sandbox Code Playgroud)