Does deleting row from view delete row from base table - MySQL?
Deleting a row from a view, will it delete the appropriate rows from the 开发者_如何学Pythonbase tables that the view was created upon? I am using MySQL.
Yes, it will. The only thing to watch out for, is permissions.
Quoting official docs
Some views are updatable. That is, you can use them in statements such as UPDATE, DELETE, or INSERT to update the contents of the underlying table. For a view to be updatable, there must be a one-to-one relationship between the rows in the view and the rows in the underlying table. There are also certain other constructs that make a view nonupdatable.
I deleted a view and lost my entire User table. I have a recent back up but for some reason it didn't back up the user table, I must have had it unchecked accidentally.
Essentially I have to go manually re-create every account and then edit them to use the User ID of all the content that they had posted on their original account that was deleted.
Pain in the ass. Life tip: deleting a view deletes the table it is pulling data from...
精彩评论