Alter table to add SPATIAL INDEX : Index « Geometric « SQL / MySQL






Alter table to add SPATIAL INDEX

    
mysql>
mysql>
mysql> CREATE TABLE mountain (
    -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    -> pt POINT NOT NULL );
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> ALTER TABLE mountain ADD SPATIAL INDEX(pt);
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql> CREATE SPATIAL INDEX pt ON mountain(pt);
ERROR 1061 (42000): Duplicate key name 'pt'
mysql>
mysql> EXPLAIN SELECT * FROM mountain;
+----+-------------+----------+--------+---------------+------+---------+------+------+---------------------+
| id | select_type | table    | type   | possible_keys | key  | key_len | ref  | rows | Extra               |
+----+-------------+----------+--------+---------------+------+---------+------+------+---------------------+
|  1 | SIMPLE      | mountain | system | NULL          | NULL | NULL    | NULL |    0 | const row not found |
+----+-------------+----------+--------+---------------+------+---------+------+------+---------------------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> drop table mountain;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
  








Related examples in the same category

1.Indexing Geometric Data