官术网_书友最值得收藏!

DELETE

The DELETE statement deletes data from a specific table of a database. For example, the following command deletes a data from the user table that carries the ID 1:

DELETE FROM user WHERE id = 1;

Even though you can use this statement to delete unwanted data, it is not recommended to delete any data from your database because the action cannot be undone. It is better to add another column to your table called status and use that to indicate whether data should be shown or not. For example, if your user deletes data on the front end application, set the status of that data to (let's say) 1 instead of 0. Then, when you want to display data on the front end, display only the data that carries a status of 0:

This way, any data that has been accidentally deleted can be recovered with ease. You can also use a BOOLEAN type for this if you only plan to use true or false. I usually use TINYINT just in case I need a third or fourth status in the future. For more information regarding the DELETE statement, you can refer to the following link:

https://dev.mysql.com/doc/refman/5.7/en/delete.html

主站蜘蛛池模板: 武定县| 盘锦市| 滕州市| 文化| 尼勒克县| 晋州市| 元江| 文水县| 玉环县| 木兰县| 额尔古纳市| 濉溪县| 蒙自县| 津市市| 蛟河市| 灵石县| 慈利县| 花莲市| 虹口区| 金门县| 临夏县| 澄迈县| 武川县| 武义县| 萨迦县| 黑河市| 库伦旗| 呼和浩特市| 鹿邑县| 谢通门县| 磴口县| 西城区| 延寿县| 安丘市| 金溪县| 东兰县| 汤阴县| 四川省| 洛扎县| 沂南县| 牡丹江市|