Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unique key & spatial column

Status
Not open for further replies.

agricola

Technical User
Sep 11, 2003
2
YU
I need unique (or primary) key with spatial (POINT) column. But when i try somthing like:

mysql> create table m (g Point primary key);
mysql> insert into m (g) values (PointFromText('point(1 1)'));
mysql> insert into m (g) values (PointFromText('point(1 2)'));
ERROR 1062: Duplicate entry '' for key 1

Why it's duplicate entry & how to do it?

 
What happens (presumably) is that the function invocations PointFromText('point(1 1)') and PointFromText('point(1 2)')
fails and in ordinary Mysql sloppy fashion a default value is inserted. (Instead of returning an error.)

You need to check the exact syntax for the parameters to the PointFromText function.
 
That fuctions are implementation of OpenGIS for spatial data. I'm using it with MySQL 4.1.0-alfa.
Check this:
mysql> CREATE TABLE t1 (g POINT);
mysql> INSERT t1 SET g=PointFromWKB(Point(1,1));
mysql> INSERT t1 SET g=PointFromWKB(Point(0,0));
mysql> INSERT t1 SET g=PointFromWKB(Point(1,0));
mysql> SELECT asText(g) From t1;
+------------+
| asText(g) |
+------------+
| POINT(1 1) |
| POINT(0 0) |
| POINT(1 0) |
+------------+
3 rows in set (0.21 sec)
mysql> CREATE UNIQUE INDEX i_1 ON t1(g);
ERROR 1062: Duplicate entry '' for key 1

!!!Gives me the same error !!!!
There is command with syntax:
CREATE SPATIAL INDEX index_name ON table(spatial_column);
but it's helples cose does not work CREATE UNIQUE SPATIAL INDEX)....
What is a diference beetwin SPATIAL & (normal) INDEX ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top