微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

MySQL 5.7 -> 8 迁移:如何更改现有 MySQL 几何列的 SRID?

如何解决MySQL 5.7 -> 8 迁移:如何更改现有 MySQL 几何列的 SRID?

我正在将一个大型数据库MysqL 5.7 迁移到 8。它包含几何列和空间索引。这是一个实时系统,因此迁移的停机时间是一个问题。

MysqL 8 会忽略空间索引,除非该列具有 SRID。建议 here 是重新定义列以具有显式 SRID 属性并重新创建 SPATIAL 索引。

我正在尝试这样做,但遇到了鸡/蛋的情况:

MysqL>  UPDATE noticeboards SET position = ST_SRID(position,4236);
ERROR 3643 (HY000): The SRID of the geometry does not match the SRID
of the column 'position'. The SRID of the geometry is 4236,but the
SRID of the column is 0. Consider changing the SRID of the geometry or
the SRID property of the column.

好的,我试试:

MysqL> ALTER TABLE noticeboards MODIFY position Geometry NOT NULL SRID 4326;
ERROR 3643 (HY000): The SRID of the geometry does not match the SRID of the column 
'position'. The SRID of the geometry is 0,but the SRID of the column is 4326. 
Consider changing the SRID of the geometry or the SRID property of the column.

如果我截断表,那么我可以执行 ALTER - 但其中一些表有外键,因此截断是一个可怕的前景。

我是否缺少将现有数据从 5.7 认 SRID 0 强制转换为另一个值的方法

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。