1Z0-909 · Question #16
Examine this statement and output: CREATE TABLE geom (g GEOMETRY NOT NOLL, SPATIAL INDEX(g) ); Query OK, 0 rows affected, 1 warning (0.01 sec) An attempt is made to add an SRID attribute to the…
The correct answer is C. An error is generated because the index prevents changes to the column. Option C is correct because MySQL does not permit altering a geometry column's SRID attribute while a SPATIAL INDEX exists on that column - the index must be dropped first, then the column modified, then the index recreated. The ALTER TABLE statement will fail with an error…
Question
Examine this statement and output:
CREATE TABLE geom (g GEOMETRY NOT NOLL, SPATIAL INDEX(g) ); Query OK, 0 rows affected, 1 warning (0.01 sec) An attempt is made to add an SRID attribute to the column using the statement:
ALTER TABLE geom MODIFY COLUMN g geometry NOT NULL SRID 0; Which is true?
Options
- AAn error is generated because srid o is an invalid identifier value.
- BExecution succeeds with a warning.
- CAn error is generated because the index prevents changes to the column.
- DExecution succeeds and allows the use of the index by the optimizer.
How the community answered
(56 responses)- A11% (6)
- B20% (11)
- C64% (36)
- D5% (3)
Explanation
Option C is correct because MySQL does not permit altering a geometry column's SRID attribute while a SPATIAL INDEX exists on that column - the index must be dropped first, then the column modified, then the index recreated. The ALTER TABLE statement will fail with an error citing the conflicting index, not merely produce a warning.
Why the distractors are wrong:
- A is wrong because
SRID 0is a perfectly valid identifier in MySQL, representing a Cartesian (undefined) coordinate system - it is not an invalid value. - B is wrong because execution does not succeed at all; the presence of the spatial index causes a hard error, not a warning.
- D is wrong because while adding an SRID constraint would theoretically help the optimizer use the spatial index, the statement never succeeds - you never reach that outcome.
Memory tip: Think "Spatial index = column frozen." Any attempt to add or change SRID restrictions on an indexed geometry column requires a drop-modify-recreate sequence. The index guards the column definition, not just the data.
Topics
Community Discussion
No community discussion yet for this question.