Find the bugs: checking data before changing a column
Before running a migration, check the existing data. The maximum length of iv_users.topics will be reduced from 50 to 8 characters. Find every user whose current topics value is too long for the new column. The values contain only Latin letters and commas. Your query should return id, topics, and the length of each value, sorted by id. Mark the lines that contain errors.
Find the errorsDDL, keys, and normalizationJuniorBackendData EngineerQA
Input data · iv_users
| id | topics | |
|---|---|---|
| 1 | ann@example.com | sql,python |
| 2 | NULL | mysql |
| 3 | boris@example.com | python,sql |
| 4 | clara@example.com | nosql,go |
| 5 | dan@example.com | sql |
SELECT id,
topics,
LENGTH(topics) AS topic_len
FROM iv_users
WHERE LENGTH(topics) >= 8
ORDER BY id