Delete語句
基本語法:
delete from 表名 where 條件
注意事項:
1,如果不使用where子句,將表中所有數據全部刪除
delete from test;
2,如果要刪除某列的值,delete是不可以做到的
3,刪除整個表 drop table 表名
4,當使用delete的時候,一定要考慮表之間參照完整性
案例:
刪除某一行記錄
delete from stu where name='aaa';
刪除所有行
delete from stu;
PS:可以使用 rollback回滾
物理刪除
truncate table stu;
注意:一旦使用了truncate表中數據將不可恢復,刪除速度快,當確定表中的數據確實沒有用並且表很大的時候可以使用truncate刪除(慎用)