Ich versuche, einen räumlichen Index zu einer Tabellenspalte namens Speicherort des Typs BLOB hinzuzufügen. Wenn ich versuche, dies:Fehler beim Erstellen räumlicher Index auf MySql BLOB-Spalte
ALTER TABLE route ADD SPATIAL INDEX(Location);
ich:
Error: BLOB/TEXT column 'Location' used in key specification without a key length
Aber in der official docs for MySql 5.1 (die Version ich verwende), sagt es deutlich, wenn sie räumlichen Indizes beziehen:
"In MySQL 5.1, column prefix lengths are prohibited. The full width of each column is indexed."
Das sagt sicher, dass ich kein Präfix angeben muss. Ich habe versucht, das Hinzufügen eines Präfix sowieso wie folgt aus:
ALTER TABLE route ADD SPATIAL INDEX(Location(256));
Und ich bekomme:
Error: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
Was zum Teufel ist hier los ?? Für Informationen, ich bin mit MySQL 5.1.37 Community, und mein Tisch ist MyISAM, das ist die Aussage erstellen:
CREATE TABLE `climb`.`route` (
`Id` int(11) NOT NULL,
`Name` varchar(255) NOT NULL,
`Location` blob,
PRIMARY KEY (`Id`),
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
PS Ich habe auch versucht haben, Location NOT NULL machen, dies keinen Unterschied gemacht.
Korrigiert, obwohl MySql die Verwendung von BLOBs für Geometrie-Spalten (http://dev.mysql.com/doc/refman/5.1/en/gis-wkb-format.html) im Well-Known Binary (WKB) Format unterstützt, Es scheint, dass Sie keinen räumlichen Index haben können. Der Trick war, Fluent NHibernate dafür zu bekommen, ich musste den SQL-Typ mit .CustomSqlTypeIs ("GEOMETRY") erzwingen. –