Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
WHERE (geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL); 

of course removes offending rows

share|improve this answer

Your Answer


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.