在AZURE SQL中创建空间索引时出错



我正在尝试在Azure SQL上创建geography数据类型的空间索引。这是代码:

CREATE SPATIAL INDEX IX_Shop_LatLong ON Shop(LatLong) 
USING GEOGRAPHY_GRID WITH (GRIDS = (LEVEL_1 = HIGH, LEVEL_2 = MEDIUM, LEVEL_3 = MEDIUM, LEVEL_4 = MEDIUM), CELLS_PER_OBJECT = 16, DROP_EXISTING = ON)

我得到的错误是:

Could not find the spatial index 'IX_Shop_LatLong' on table 'Shop'. Either no spatial index with this name exists, or a non-spatial index might be using the same name. Fix the index name, avoiding duplicates. If a  relational index has the same name, drop the regular relational index.

我试着给其他人起名字,但我也犯了同样的错误。

此错误表示由于使用DROP_EXISTING=ON选项,因此不存在可修改的空间索引定义。使用此选项,需要存在匹配的索引(正确类型),否则会出现此错误。如果在表上从头开始创建索引,则需要省略DROP_EXISTING=on选项。您应该将CREATE INDEX WITH DROP_EXISTING=ON视为ALTER INDEX操作。它不会创建对象本身。希望这能有所帮助。

最新更新