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

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

主站蜘蛛池模板: 田林县| 安吉县| 德州市| 福贡县| 宜丰县| 香港| 舟山市| 广南县| 平乐县| 辉南县| 涿鹿县| 岑溪市| 通榆县| 新闻| 台东市| 甘孜县| 西乌珠穆沁旗| 泽州县| 南江县| 杭锦旗| 义马市| 普安县| 资兴市| 旬邑县| 四子王旗| 涟水县| 祁阳县| 彝良县| 昭苏县| 教育| 翁牛特旗| 卓资县| 台东市| 隆德县| 应用必备| 山西省| 施甸县| 河曲县| 屏东县| 益阳市| 喀喇沁旗|