Does deleting row from view delete row from base table - MySQL?

后端 未结 2 1833
-上瘾入骨i
-上瘾入骨i 2020-12-11 02:42

Deleting a row from a view, will it delete the appropriate rows from the base tables that the view was created upon? I am using MySQL.

相关标签:
2条回答
  • 2020-12-11 03:10

    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.

    0 讨论(0)
  • 2020-12-11 03:13

    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...

    0 讨论(0)
提交回复
热议问题