Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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"

share|improve this question
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

1 Answer 1

DELETE FROM table 
WHERE (geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL); 

of course removes offending rows

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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