下面是我的表架构和数据。
#Table Structure
CREATE TABLE public.route
(
name text NOT NULL,
startpoint point NOT NULL,
endpoint point NOT NULL,
id integer NOT NULL DEFAULT nextval('route_id_seq'::regclass),
CONSTRAINT route_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
#Table Data
INSERT INTO public.route (name, startpoint, endpoint, id) VALUES ('Atlantic', (-73.848838,40.688299), (-73.824869,40.694831), 1);
INSERT INTO public.route (name, startpoint, endpoint, id) VALUES ('Guy Brewer', (-73.7991,40.708257), (-73.78543,40.688334), 2);
想要检查startpoint
列中(-73.848838,40.688299)
列是否有route
答案 0 :(得分:0)
SELECT *
FROM route
WHERE startpoint ~= POINT '(-73.848838,40.688299)';
您可以使用GiST索引加快速度:
CREATE INDEX ON route USING gist (startpoint);