1

I have table that containing road network. Table structure is

CREATE TABLE final_all_india_road_network
(
  gid serial NOT NULL,
  "name" character varying(254),
  code character varying(254),
  lane character varying(254),
  width integer,
  "type" character varying(254),
  subclass character varying(254),
  surface character varying(254),
  oneway character varying(254),
  bridge integer,
  maxspeed integer,
  the_geom geometry,
  CONSTRAINT final_all_india_road_network_pkey PRIMARY KEY (gid),
  CONSTRAINT enforce_dims_the_geom CHECK (st_ndims(the_geom) = 2),
  CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 4030)
)

I want to add check geometry constraints to this table. For that I used following Query

"ALTER TABLE final_all_india_road_network
  ADD CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL);"

But while running this Query following error occured

"ERROR: check constraint "enforce_geotype_the_geom" is violated by some row"

  • 3
    Seems clear that you already have a row in the table that violates your proposed geometry constraint. It could be a simple linestring, or a fragment point. – L_Holcombe Oct 11 '12 at 5:40
2
DELETE FROM table 
WHERE (geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL); 

of course removes offending rows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.