MySQL Updatable and Insertable Views

Learning about Updatable and Insertable Views in MySQL. I was getting the error ER_WARN_VIEW_WITHOUT_KEY which said “View being updated does not have complete key of underlying table in it.”

You would have thought that error message was entirely self-explanatory, but it took me a while to understand the problem. The problem was, well, er, that the view being updated didn’t have the complete key of the underlying table in it.

For those of you who are dense like I am, that means that the primary key for the underlying table hadn’t been included as a column in the view definition. I’d done some processing on the actual primary key to turn it from upper case to lower case, and this processing meant the underlying key wasn’t actually in the view I was updating, because the primary key had been modified slightly in the view definition. I got rid of the warning by just adding the primary key column unprocessed at the end of the column list and that got rid of the warning.