sql example 7 – delete
sql example 7 – delete
delete from user1 where id=99;
select * from user1;
| id | username | +----+----------+ | 1 | user1 | | 2 | user2 | | 3 | user3 | | 99 | I am 99 |
delete from user1 where id=99;
select * from user1;
| id | username | +----+----------+ | 1 | user1 | | 2 | user2 | | 3 | user3 |
删除表中全部的数据
delete from user1;
delete from user1;
select * from user1;
Empty set (0.00 sec)
使用 delete 的时候最后先用 select 看下
select * from .. 的结果就是 delete from ... 执行的时候被删除的东向
清空一个表是使用 truncate table user1
等价上面的 delete from user1
删除一个表是使用 drop table tablename
删除一个数据库使用 drop database databasename
时间: 2024-10-17 14:45:36