-- The table issimple_test is created with two columns. -- The pid column is a smallint containing the unique -- identifier for each row. The g1 ST_Geometry column -- stores the simple and nonsimple geometry samples. CREATE TABLE issimple_test (pid smallint, g1 ST_Geometry); -- The INSERT statements insert two records into the issimple_test -- table. The first is a simple linestring because it -- doesn't intersect its interior. The second is nonsimple -- because it does intersect its interior. INSERT INTO issimple_test VALUES( 1, ST_LineFromText('linestring (10 10, 20 20, 30 30)',1000) ); INSERT INTO issimple_test VALUES( 2, ST_LineFromText('linestring (10 10,20 20,20 30,10 30,10 20,20 10)',1000) ); -- The query returns the results of the ST_IsSimple function. -- The first record returns t (TRUE) because the linestring is simple, while -- the second record returns f (FALSE) because the linestring is not simple. SELECT pid, ST_IsSimple(g1) Is_it_simple FROM issimple_test;