mysql - MySQL 5.7 -> 8 迁移:如何更改现有 MySQL 几何列的 SRID?
问题描述
我正在将一个大型数据库从 MySQL 5.7 迁移到 8。它包含几何列和空间索引。这是一个实时系统,因此迁移的停机时间是一个问题。
MySQL 8 忽略空间索引,除非列具有 SRID。此处的建议是重新定义列以具有显式 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 强制转换为另一个值的方法?
解决方案
推荐阅读
- javascript - 尝试在网页中显示酒店数据的 Amadeus Test Api 时出错
- amazon-web-services - 是否可以覆盖 AWS SAM 策略模板占位符变量
- python - 没有换行符的数字字符串的正则表达式
- java - 想从 Docker 运行 mysql 并用 springboot 连接
- php - 如何将图像发送到 Laravel 8 中的 Stripe Checkout Session
- c - C 函数 printf 中格式说明符的手册页在哪里?
- c - 确定 C 中字符串输入的内存分配大小(scanf)
- swiftui - 为什么我的 AVVideoCapturePreview 不在图层中渲染?
- kotlin - 如何使用 Kotlin 将代码转换为委托?
- splunk - Splunk:使用唯一字段记录重复数据删除