0

I've added a POINT column to a rather large existing table. I had to set it null initially as required by MySQL. I then executed successfully:

update geoloc set geoPoint = ST_SRID( POINT( 0, 0 ), 4326)

Next, when I tried to add a spatial index to this column, I got

ERROR 1252: All parts of a SPATIAL index must be NOT NULL

I tried "SELECT * from geoloc where geoPoint is null" and got 0 results.

So there are no null values in the column, but the index fails telling me I can't have a null. What am I missing?

1 Answer 1

1

try:

-- Step 1: Ensure no NULL values (already done)
UPDATE geoloc SET geoPoint = ST_SRID(POINT(0, 0), 4326) WHERE geoPoint IS NULL;

-- Step 2: Modify the column to NOT NULL
ALTER TABLE geoloc MODIFY COLUMN geoPoint POINT NOT NULL;

-- Step 3: Add the spatial index
ALTER TABLE geoloc ADD SPATIAL INDEX (geoPoint);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. That worked. A bit curious about the reason for having to do it this way. But it works now, and that's all that matters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.