删除的操作很危险,需要谨慎使用。
1,初级删除
delete from invoices
where invoice_id=1
2,子查询删除
delete from invoices
where client_id=
(select client_id
from clients
where name='Myworks')
以上client_id不能写成*,不然报错Error Code: 1241. Operand should contain 1 column(s)
3,恢复数据库
file--open sql script--打开create-databases--运行-刷新数据库。

如果出现unknown fileencoding,可能是文件夹未知含有中文名称,改英文,再重新操作上述的就行
打开了invoices这张表,client_id为2的记录恢复了,说明数据库恢复到原样了。
本文介绍了如何在SQL中谨慎执行删除操作,包括基本的删除语句、通过子查询删除特定客户记录,以及遇到错误时如何恢复数据库。特别提到处理unknownfileencoding问题和恢复特定client_id的数据实例。

被折叠的 条评论
为什么被折叠?



