mysql 练习基础 9:删除数据并手动导入数据

2021/10/10 16:50:35

本文主要是介绍mysql 练习基础 9:删除数据并手动导入数据,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

truncate table orders;-- 删除表orders数据

#删除数据
# delete from 表名[ where 删除条件];
# truncate 表名;(与delete from 表名一样,都是删除表中全部数据,保留表结构)
#delete和truncate的区别:
#dlete可以添加where子句删除表中部分数据,truncate只能删除表中全部数据
#dlete删除表中数据保留表结构,truncate直接把表删除(drop table)然后再创建一张新表(create table),执行速度比delete快。

insert into orders values
("o01","u01","c01","2021-10-1"),
("o02","u01","c01","2021-10-2"),
("o03","u01","c01","2021-10-2"),
("o04","u02","c02","2021-10-03"),
("o05","u03","c02","2021-10-30"),
("o06","u03","c02","2021-10-01"),
("o07","u04","c03","2021-10-03"),
("o08","u04","c03","2021-10-04"),
("o09","u04","c03","2021-10-04"),
("o10","u04","c03","2021-10-06");

select * from orders;-- 查看导入数据结果

 



这篇关于mysql 练习基础 9:删除数据并手动导入数据的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程